Spring Boot应用程序无法在CloudFoundry中启动

aaaaarrrgghhh

我有一个使用maven jdk1.8构建的Spring Boot应用程序。它使用嵌入式Tomcat和jar打包。我正在使用Spring Tool Suite将应用程序推送到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 Boot标语,没有来自我的应用程序的启动消息-没什么。如果我浏览URL,我只会得到404(这意味着Tomcat正在运行!)。

我试过了

cf文件

但是意识到这是在迭戈上,所以我尝试了

cf ssh MY-APP

并查看了logs目录-根本没有,没有一个文件。

cf-events

只是说该应用已启动。

CloudFoundry中的GUI控制台愉快地报告其“正在运行”,我什至如何开始对此进行故障排除?

清单文件

---
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>

主班

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
   }
 }
}
aaaaarrrgghhh

经过半天的耕p,我发现了问题。对于不耐烦的人来说,这是由于这个问题[spring boot and java buildpack] [1] https://github.com/spring-projects/spring-boot /问题/ 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"}

上面的链接说明了问题以及如何解决此问题(使用最新的java-buildpack(使用cf cli的-b开关指定),因此,如果有人在将Spring Boot应用程序推送到Cloud Foundry时看到此异常,您可能会知道潜在的问题!

ERR Caused by: java.lang.IllegalArgumentException: Cannot instantiate 
interface org.springframework.context.ApplicationContextInitializer :org.cloudfoundry.reconfiguration.spring.CloudPropertySourceApplicationContextInitializer

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

使Spring Boot应用程序启动更快

Spring应用程序无法启动

无法加载在Docker中运行的Spring Boot应用程序

无法启动Spring Boot应用程序NoClassDefFoundError

无法在不同的Spring Boot应用程序中的不同端口上启动2个嵌入式active-mq

无法从JUnit的Spring Boot中读取应用程序属性?

Intellij Spring Boot应用程序无法在Tomcat中运行

无法在Spring Boot应用程序中配置ViewResolver

为什么我的Spring Boot应用程序首先失败,然后突然在cloudfoundry中启动?

Spring Boot Web应用程序无法启动

无法在IntelliJ中启动Spring Boot + thymeleaf应用程序

Java / Spring应用程序无法在cloudfoundry上启动:OutOfMemoryError压缩的类空间

无法启动Spring Boot Web应用程序

应用程序启动失败-Spring Boot

Jetty无法在AppEngine flexible中启动Spring Boot应用程序

配置spring-session-data-redis后无法启动spring-boot应用程序

在Spring Boot应用程序中无法解析占位符

Spring Boot 2.0.3.RELEASE,Spring数据保留,应用程序错误,无法启动

JMS未在Spring Boot应用程序中启动

在Spring Boot应用程序中无法解析表“'xx”

Spring Data Cassandra无法启动的Spring Boot应用程序

在Spring Boot应用程序中访问cloudfoundry中用户提供的环境变量

使用简单的 Spring Boot 应用程序出现错误“应用程序无法启动”

在 Spring Boot 应用程序中启动 ApplicationContext 时出错

Spring boot - 应用程序无法启动无法打开架构管理目标的 JDBC 连接

Spring boot 应用程序启动错误

Spring Boot 应用程序无法启动?

Spring Boot + Tomcat + Jetty - 应用程序无法启动

Spring Boot 应用程序无法启动(IllegalStateException 无法评估 DevToolsDataSourceAutoConfiguration 上的条件)