Spring 引导应用程序未在 CloudFoundry 中启动
Spring Boot application does not start in CloudFoundry
我有一个 Spring 启动应用程序,是用 maven jdk1.8 构建的。
它使用嵌入式 Tomcat 和 jar 包装。
我正在使用 Spring 工具套件将应用程序推送到 CloudFoundry。推送后我在控制台中收到以下消息:
[CONTAINER] org.apache.jasper.servlet.TldScanner INFO At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
[CONTAINER] org.apache.catalina.startup.HostConfig INFO Deployment of web application directory /home/vcap/app/.java-buildpack/tomcat/webapps/ROOT has finished in 724 ms
[CONTAINER] org.apache.coyote.http11.Http11NioProtocol INFO Starting ProtocolHandler ["http-nio-8080"]
[CONTAINER] org.apache.tomcat.util.net.NioSelectorPool INFO Using a shared selector for servlet write/read
[CONTAINER] org.apache.catalina.startup.Catalina INFO Server startup in 814 ms
healthcheck passed
Container became healthy
Exit status 0
[Application Running Check] - Application appears to be running - MY-APP
问题是 - 没有 Spring 启动横幅,我的应用程序没有启动消息 - 什么都没有。
如果我浏览 URL,我只会得到 404(这意味着 Tomcat 不知何故是 运行!)。
我试过了
cf files
但意识到这是在 Diego 上,所以我尝试了
cf ssh MY-APP
并查看了日志目录 - 那里什么也没有,一个文件也没有。
和
cf-events
只是说应用已经启动。
CloudFoundry 中的 GUI 控制台愉快地报告它 'Running'
我什至如何开始解决这个问题?
Manifest.yml
---
applications:
- name: MY-APP
memory: 1024M
host: my-app
domain: xxx.yyy.com
services:
- p-mysql
instances: 1
application.properties
spring.jpa.hibernate.ddl-auto=update
spring.datasource.url = jdbc:mysql://<ip_addr>:3306/<db_name>?user=<user_name>&password=<password>
spring.datasource.username = <username>
spring.datasource.password = <password>
spring.thymeleaf.cache: false
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>MyAPP</groupId>
<artifactId>my-app</artifactId>
<version>0.2</version>
<name>my-app</name>
<description>Attempt2</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.0.M1</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<!--<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency> -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>bootstrap</artifactId>
<version>3.3.4</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>jquery</artifactId>
<version>2.1.4</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>sonatype-nexus-snapshots</id>
<name>Sonatype Nexus Snapshots</name>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf</artifactId>
<version>2.1.5-SNAPSHOT</version>
</dependency>
</dependencies>
</dependencyManagement>
主要class
package com.sa;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class MyAppApplication {
public static void main(String[] args) {
SpringApplication.run(MyAppApplication.class, args);
}
}
CloudFoundry 环境变量
{
"staging_env_json": {},
"running_env_json": {},
"system_env_json": {
"VCAP_SERVICES": {
"p-mysql": [
{
"name": "p-mysql",
"label": "p-mysql",
"tags": [
"mysql",
"relational"
],
"plan": "pre-existing-plan",
"credentials": {
"hostname": "<ip-addr>",
"port": 3306,
"name": "db-name",
"username": "<username>",
"password": "<password>",
"uri": "mysql://<username>:<pass>@<ip_addr>:3306/<db-name>?reconnect=true",
"jdbcUrl": "jdbc:mysql://<ip_addr>:3306/<db-name>?user=<username>&password=<pass>"
}
}
]
}
},
"application_env_json": {
"VCAP_APPLICATION": {
"limits": {
"mem": 1024,
"disk": 1024,
"fds": 16384
},
"application_id": "<some string>",
"application_version": "<some other string>",
"application_name": "my-app",
"application_uris": [
"my-app.xxx.yyy.com"
],
"version": "2d5fd7b0-a1c2-4039-8eed-fb6e25772dee",
"name": "my-app",
"space_name": "xyz",
"space_id": "<some string>",
"uris": [
"my-app.xxx.yyy.com"
],
"users": null
}
}
}
折腾了半天,发现problem.For不耐烦,就是因为这个问题
[spring 引导和 java buildpack][1]https://github.com/spring-projects/spring-boot/issues/4897
我没有从 STS 推送中得到任何东西,所以我恢复到 CLI。
第一的,
mvn clean package
然后
cf push -p PATH-to-Jar
有一整条错误消息(终于!有东西要看!),以
结尾
2016-05-14T21:22:46.71+0800 [API/0] OUT App instance exited with guid 83ec77d4-bcc5-4b12-8430-dd0a4d140b22 payload: {"instance"=>"27dc9686-1853-4 465-745e-55e450ee94c4", "index"=>0, "reason"=>"CRASHED",
"exit_description"=>"2 error(s) occurred:\n\n* 2 error(s) occurred:\n\n*
Exited with status 1
\n* cancelled\n* cancelled", "crash_count"=>3, "crash_timestamp"=>1463232166690142658, "version"=>"b37907a9-f4d6-4045-987c-f7bddb5e7a5c"}
上面的link解释了这个问题以及如何解决它(使用最新的java-buildpack(用cf cli的-b开关指定),所以如果有人在推送时看到这个异常spring 将应用程序引导至 Cloud Foundry,您知道潜在的问题是什么!
ERR Caused by: java.lang.IllegalArgumentException: Cannot instantiate
interface org.springframework.context.ApplicationContextInitializer :org.cloudfoundry.reconfiguration.spring.CloudPropertySourceApplicationContextInitializer
我有一个 Spring 启动应用程序,是用 maven jdk1.8 构建的。 它使用嵌入式 Tomcat 和 jar 包装。 我正在使用 Spring 工具套件将应用程序推送到 CloudFoundry。推送后我在控制台中收到以下消息:
[CONTAINER] org.apache.jasper.servlet.TldScanner INFO At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
[CONTAINER] org.apache.catalina.startup.HostConfig INFO Deployment of web application directory /home/vcap/app/.java-buildpack/tomcat/webapps/ROOT has finished in 724 ms
[CONTAINER] org.apache.coyote.http11.Http11NioProtocol INFO Starting ProtocolHandler ["http-nio-8080"]
[CONTAINER] org.apache.tomcat.util.net.NioSelectorPool INFO Using a shared selector for servlet write/read
[CONTAINER] org.apache.catalina.startup.Catalina INFO Server startup in 814 ms
healthcheck passed
Container became healthy
Exit status 0
[Application Running Check] - Application appears to be running - MY-APP
问题是 - 没有 Spring 启动横幅,我的应用程序没有启动消息 - 什么都没有。 如果我浏览 URL,我只会得到 404(这意味着 Tomcat 不知何故是 运行!)。
我试过了
cf files
但意识到这是在 Diego 上,所以我尝试了
cf ssh MY-APP
并查看了日志目录 - 那里什么也没有,一个文件也没有。 和
cf-events
只是说应用已经启动。
CloudFoundry 中的 GUI 控制台愉快地报告它 'Running' 我什至如何开始解决这个问题?
Manifest.yml
---
applications:
- name: MY-APP
memory: 1024M
host: my-app
domain: xxx.yyy.com
services:
- p-mysql
instances: 1
application.properties
spring.jpa.hibernate.ddl-auto=update
spring.datasource.url = jdbc:mysql://<ip_addr>:3306/<db_name>?user=<user_name>&password=<password>
spring.datasource.username = <username>
spring.datasource.password = <password>
spring.thymeleaf.cache: false
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>MyAPP</groupId>
<artifactId>my-app</artifactId>
<version>0.2</version>
<name>my-app</name>
<description>Attempt2</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.0.M1</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<!--<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency> -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>bootstrap</artifactId>
<version>3.3.4</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>jquery</artifactId>
<version>2.1.4</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>sonatype-nexus-snapshots</id>
<name>Sonatype Nexus Snapshots</name>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf</artifactId>
<version>2.1.5-SNAPSHOT</version>
</dependency>
</dependencies>
</dependencyManagement>
主要class
package com.sa;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class MyAppApplication {
public static void main(String[] args) {
SpringApplication.run(MyAppApplication.class, args);
}
}
CloudFoundry 环境变量
{
"staging_env_json": {},
"running_env_json": {},
"system_env_json": {
"VCAP_SERVICES": {
"p-mysql": [
{
"name": "p-mysql",
"label": "p-mysql",
"tags": [
"mysql",
"relational"
],
"plan": "pre-existing-plan",
"credentials": {
"hostname": "<ip-addr>",
"port": 3306,
"name": "db-name",
"username": "<username>",
"password": "<password>",
"uri": "mysql://<username>:<pass>@<ip_addr>:3306/<db-name>?reconnect=true",
"jdbcUrl": "jdbc:mysql://<ip_addr>:3306/<db-name>?user=<username>&password=<pass>"
}
}
]
}
},
"application_env_json": {
"VCAP_APPLICATION": {
"limits": {
"mem": 1024,
"disk": 1024,
"fds": 16384
},
"application_id": "<some string>",
"application_version": "<some other string>",
"application_name": "my-app",
"application_uris": [
"my-app.xxx.yyy.com"
],
"version": "2d5fd7b0-a1c2-4039-8eed-fb6e25772dee",
"name": "my-app",
"space_name": "xyz",
"space_id": "<some string>",
"uris": [
"my-app.xxx.yyy.com"
],
"users": null
}
}
}
折腾了半天,发现problem.For不耐烦,就是因为这个问题 [spring 引导和 java buildpack][1]https://github.com/spring-projects/spring-boot/issues/4897
我没有从 STS 推送中得到任何东西,所以我恢复到 CLI。
第一的,
mvn clean package
然后
cf push -p PATH-to-Jar
有一整条错误消息(终于!有东西要看!),以
2016-05-14T21:22:46.71+0800 [API/0] OUT App instance exited with guid 83ec77d4-bcc5-4b12-8430-dd0a4d140b22 payload: {"instance"=>"27dc9686-1853-4 465-745e-55e450ee94c4", "index"=>0, "reason"=>"CRASHED",
"exit_description"=>"2 error(s) occurred:\n\n* 2 error(s) occurred:\n\n*
Exited with status 1
\n* cancelled\n* cancelled", "crash_count"=>3, "crash_timestamp"=>1463232166690142658, "version"=>"b37907a9-f4d6-4045-987c-f7bddb5e7a5c"}
上面的link解释了这个问题以及如何解决它(使用最新的java-buildpack(用cf cli的-b开关指定),所以如果有人在推送时看到这个异常spring 将应用程序引导至 Cloud Foundry,您知道潜在的问题是什么!
ERR Caused by: java.lang.IllegalArgumentException: Cannot instantiate
interface org.springframework.context.ApplicationContextInitializer :org.cloudfoundry.reconfiguration.spring.CloudPropertySourceApplicationContextInitializer