我有一个Spring Boot Application(独立jar文件),我试图在CloudFoundry上部署它。我在CloudFoundry上创建了一个Service Registry实例,并尝试使用CloudFoundry CLI推送(cf push -p target\microservice-user-service-0.0.1-SNAPSHOT.jar)
我的应用程序(用户服务)。
成功上传应用程序,服务绑定也成功发生。一旦启动,它就会给健康检查失败问题
2016-06-21T16:13:13.79-0400 [APP/0] OUT 16: DEBUG StandardServletEnvironment - Initialized StandardServletEnvironment with PropertySources [servletConfigInitParams,servletContextInitParams,systemProperties,systemEnvironment]
2016-06-21T16:13:13.79-0400 [APP/0] OUT 16: DEBUG WebappClassLoaderBase - findClass(java.lang.ObjectCustomizer)
2016-06-21T16:13:13.79-0400 [APP/0] OUT 16: DEBUG WebappClassLoaderBase - --> Returning ClassNotFoundException
2016-06-21T16:13:13.79-0400 [APP/0] OUT 16: DEBUG WebappClassLoaderBase - findClass(org.springframework.web.filter.GenericFilterBeanCustomizer)
2016-06-21T16:13:13.79-0400 [APP/0] OUT 16: DEBUG WebappClassLoaderBase - --> Returning ClassNotFoundException
2016-06-21T16:13:13.79-0400 [APP/0] OUT 16: DEBUG WebappClassLoaderBase - findClass(org.springframework.security.web.FilterChainProxyCustomizer)
2016-06-21T16:13:13.79-0400 [APP/0] OUT 16: DEBUG WebappClassLoaderBase - --> Returning ClassNotFoundException
2016-06-21T16:13:13.80-0400 [APP/0] OUT 16: DEBUG DelegatingFilterProxy - Filter 'springSecurityFilterChain' configured successfully
2016-06-21T16:13:13.80-0400 [APP/0] OUT 16: DEBUG Registry - Managed= Tomcat:j2eeType=Filter,WebModule=//localhost/,name=springSecurityFilterChain,J2EEApplication=none,J2EEServer=none 2016-06-21T16:13:13.80-0400 [APP/0] OUT 16: DEBUG BaseModelMBean - preRegister ApplicationFilterConfig[name=springSecurityFilterChain, filterClass=org.springframework.web.filter.DelegatingFilterProxy] Tomcat:j2eeType=Filter,WebModule=//localhost/,name=springSecurityFilterChain,J2EEApplication=none,J2EEServer=none
2016-06-21T16:13:13.80-0400 [APP/0] OUT 16: DEBUG [/] - Starting filter 'webRequestLoggingFilter' 2016-06-21T16:13:13.80-0400 [APP/0] OUT 16: DEBUG Registry - Managed= Tomcat:j2eeType=Filter,WebModule=//localhost/,name=webRequestLoggingFilter,J2EEApplication=none,J2EEServer=none
2016-06-21T16:13:13.80-0400 [APP/0] OUT 16: DEBUG BaseModelMBean - preRegister ApplicationFilterConfig[name=webRequestLoggingFilter, filterClass=org.springframework.boot.actuate.trace.WebRequestTraceFilter] Tomcat:j2eeType=Filter,WebModule=//localhost/,name=webRequestLoggingFilter,J2EEApplication=none,J2EEServer=none
2016-06-21T16:13:13.80-0400 [APP/0] OUT 16: DEBUG StandardContext - Starting completed
2016-06-21T16:13:13.80-0400 [APP/0] OUT 16: DEBUG LifecycleBase - Setting state for [StandardEngine[Tomcat].StandardHost[localhost].StandardContext[]] to [STARTING]
2016-06-21T16:13:13.80-0400 [APP/0] OUT 16: DEBUG LifecycleBase - Setting state for [StandardEngine[Tomcat].StandardHost[localhost].StandardContext[]] to [STARTED]
2016-06-21T16:13:13.80-0400 [APP/0] OUT 16: DEBUG LifecycleBase - Setting state for [Pipeline[StandardEngine[Tomcat].StandardHost[localhost]]] to [INITIALIZING]
2016-06-21T16:13:13.80-0400 [APP/0] OUT 16: DEBUG LifecycleBase - Setting state for [Pipeline[StandardEngine[Tomcat].StandardHost[localhost]]] to [INITIALIZED]
2016-06-21T16:13:13.80-0400 [APP/0] OUT 16: DEBUG LifecycleBase - Setting state for [Pipeline[StandardEngine[Tomcat].StandardHost[localhost]]] to [STARTING_PREP]
2016-06-21T16:13:13.80-0400 [APP/0] OUT 16: DEBUG LifecycleBase - Setting state for [org.apache.catalina.valves.ErrorReportValve[localhost]] to [INITIALIZING]
2016-06-21T16:13:13.80-0400 [APP/0] OUT 16: DEBUG Registry - Managed= Tomcat:type=Valve,host=localhost,name=ErrorReportValve
2016-06-21T16:13:13.80-0400 [APP/0] OUT 16: DEBUG BaseModelMBean - preRegister org.apache.catalina.valves.ErrorReportValve[localhost] Tomcat:type=Valve,host=localhost,name=ErrorReportValve
2016-06-21T16:13:13.80-0400 [APP/0] OUT 16: DEBUG LifecycleBase - Setting state for [org.apache.catalina.valves.ErrorReportValve[localhost]] to [INITIALIZED]
2016-06-21T16:13:13.80-0400 [APP/0] OUT 16: DEBUG LifecycleBase - Setting state for [org.apache.catalina.valves.ErrorReportValve[localhost]] to [STARTING_PREP]
2016-06-21T16:13:13.80-0400 [APP/0] OUT 16: DEBUG LifecycleBase - Setting state for [org.apache.catalina.valves.ErrorReportValve[localhost]] to [STARTING]
2016-06-21T16:13:13.80-0400 [APP/0] OUT 16: DEBUG LifecycleBase - Setting state for [org.apache.catalina.valves.ErrorReportValve[localhost]] to [STARTED]
2016-06-21T16:13:13.80-0400 [APP/0] OUT 16: DEBUG LifecycleBase - Setting state for [org.apache.catalina.core.StandardHostValve[localhost]] to [INITIALIZING]
2016-06-21T16:13:13.80-0400 [APP/0] OUT 16: DEBUG Registry - Managed= Tomcat:type=Valve,host=localhost,name=StandardHostValve
2016-06-21T16:13:13.80-0400 [APP/0] OUT 16: DEBUG BaseModelMBean - preRegister org.apache.catalina.core.StandardHostValve[localhost] Tomcat:type=Valve,host=localhost,name=StandardHostValve
2016-06-21T16:13:13.80-0400 [APP/0] OUT 16: DEBUG LifecycleBase - Setting state for [org.apache.catalina.core.StandardHostValve[localhost]] to [INITIALIZED]
2016-06-21T16:13:13.80-0400 [APP/0] OUT 16: DEBUG LifecycleBase - Setting state for [org.apache.catalina.core.StandardHostValve[localhost]] to [STARTING_PREP]
2016-06-21T16:13:13.80-0400 [APP/0] OUT 16: DEBUG LifecycleBase - Setting state for [org.apache.catalina.core.StandardHostValve[localhost]] to [STARTING]
2016-06-21T16:13:13.80-0400 [APP/0] OUT 16: DEBUG LifecycleBase - Setting state for [org.apache.catalina.core.StandardHostValve[localhost]] to [STARTED]
2016-06-21T16:13:13.80-0400 [APP/0] OUT 16: DEBUG LifecycleBase - Setting state for [Pipeline[StandardEngine[Tomcat].StandardHost[localhost]]] to [STARTING]
2016-06-21T16:13:13.80-0400 [APP/0] OUT 16: DEBUG LifecycleBase - Setting state for [Pipeline[StandardEngine[Tomcat].StandardHost[localhost]]] to [STARTED]
2016-06-21T16:13:13.80-0400 [APP/0] OUT 16: DEBUG LifecycleBase - Setting state for [StandardEngine[Tomcat].StandardHost[localhost]] to [STARTING]
2016-06-21T16:13:13.80-0400 [APP/0] OUT 16: DEBUG LifecycleBase - Setting state for [StandardEngine[Tomcat].StandardHost[localhost]] to [STARTED]
2016-06-21T16:13:13.80-0400 [APP/0] OUT 16: DEBUG LifecycleBase - Setting state for [Pipeline[StandardEngine[Tomcat]]] to [INITIALIZING]
2016-06-21T16:13:13.80-0400 [APP/0] OUT 16: DEBUG LifecycleBase - Setting state for [Pipeline[StandardEngine[Tomcat]]] to [INITIALIZED]
2016-06-21T16:13:13.80-0400 [APP/0] OUT 16: DEBUG LifecycleBase - Setting state for [Pipeline[StandardEngine[Tomcat]]] to [STARTING_PREP]
2016-06-21T16:13:13.80-0400 [APP/0] OUT 16: DEBUG LifecycleBase - Setting state for [org.apache.catalina.core.StandardEngineValve[Tomcat]] to [INITIALIZING]
2016-06-21T16:13:13.80-0400 [APP/0] OUT 16: DEBUG Registry - Managed= Tomcat:type=Valve,name=StandardEngineValve
2016-06-21T16:13:13.80-0400 [APP/0] OUT 16: DEBUG BaseModelMBean - preRegister org.apache.catalina.core.StandardEngineValve[Tomcat] Tomcat:type=Valve,name=StandardEngineValve
2016-06-21T16:13:13.80-0400 [APP/0] OUT 16: DEBUG LifecycleBase - Setting state for [org.apache.catalina.core.StandardEngineValve[Tomcat]] to [INITIALIZED]
2016-06-21T16:13:13.80-0400 [APP/0] OUT 16: DEBUG LifecycleBase - Setting state for [org.apache.catalina.core.StandardEngineValve[Tomcat]] to [STARTING_PREP]
2016-06-21T16:13:13.80-0400 [APP/0] OUT 16: DEBUG LifecycleBase - Setting state for [org.apache.catalina.core.StandardEngineValve[Tomcat]] to [STARTING]
2016-06-21T16:13:13.80-0400 [APP/0] OUT 16: DEBUG LifecycleBase - Setting state for [org.apache.catalina.core.StandardEngineValve[Tomcat]] to [STARTED]
2016-06-21T16:13:13.80-0400 [APP/0] OUT 16: DEBUG LifecycleBase - Setting state for [Pipeline[StandardEngine[Tomcat]]] to [STARTING]
2016-06-21T16:13:13.80-0400 [APP/0] OUT 16: DEBUG LifecycleBase - Setting state for [Pipeline[StandardEngine[Tomcat]]] to [STARTED]
2016-06-21T16:13:13.80-0400 [APP/0] OUT 16: DEBUG LifecycleBase - Setting state for [StandardEngine[Tomcat]] to [STARTING]
2016-06-21T16:13:13.80-0400 [APP/0] OUT 16: DEBUG LifecycleBase - Setting state for [StandardEngine[Tomcat]] to [STARTED]
2016-06-21T16:13:13.80-0400 [APP/0] OUT 16: DEBUG LifecycleBase - Setting state for [org.apache.catalina.mapper.MapperListener@1c7c9651] to [STARTING_PREP]
2016-06-21T16:13:13.80-0400 [APP/0] OUT 16: DEBUG LifecycleBase - Setting state for [org.apache.catalina.mapper.MapperListener@1c7c9651] to [STARTING]
2016-06-21T16:13:13.80-0400 [APP/0] OUT 16: DEBUG Mapper - Registered host [localhost]
2016-06-21T16:13:13.80-0400 [APP/0] OUT 16: DEBUG MapperListener - Register Wrapper [default] in Context [] for service [StandardService[Tomcat]]
2016-06-21T16:13:13.80-0400 [APP/0] OUT 16: DEBUG MapperListener - Register Wrapper [dispatcherServlet] in Context [] for service [StandardService[Tomcat]]
2016-06-21T16:13:13.80-0400 [APP/0] OUT 16: DEBUG MapperListener - Register Context [] for service [StandardService[Tomcat]]
2016-06-21T16:13:13.80-0400 [APP/0] OUT 16: DEBUG MapperListener - Register host [localhost] at domain [null] for service [StandardService[Tomcat]]
2016-06-21T16:13:13.80-0400 [APP/0] OUT 16: DEBUG LifecycleBase - Setting state for [org.apache.catalina.mapper.MapperListener@1c7c9651] to [STARTED]
2016-06-21T16:13:13.80-0400 [APP/0] OUT 16: DEBUG LifecycleBase - Setting state for [StandardService[Tomcat]] to [STARTED]
2016-06-21T16:13:13.80-0400 [APP/0] OUT 16: DEBUG LifecycleBase - Setting state for [StandardServer[-1]] to [STARTED]
2016-06-21T16:13:13.80-0400 [APP/0] OUT 16: DEBUG StandardServletEnvironment - Replacing [servletContextInitParams] PropertySource with [servletContextInitParams]
2016-06-21T16:13:14.18-0400 [HEALTH/0] OUT healthcheck failed
2016-06-21T16:13:14.18-0400 [HEALTH/0] OUT Exit status 1
2016-06-21T16:13:14.50-0400 [APP/0] OUT 16: DEBUG LoggingRestTemplate - Created GET request for "https://api.run.pivotal.io/info"
2016-06-21T16:13:14.50-0400 [APP/0] OUT 16: DEBUG LoggingRestTemplate - Setting request Accept header to [text/plain, application/json, application/*+json, */*]
2016-06-21T16:13:14.51-0400 [APP/0] OUT 16: DEBUG RequestAddCookies - CookieSpec selected: default
2016-06-21T16:13:14.52-0400 [APP/0] OUT 16: DEBUG RequestAuthCache - Auth cache not set in the context
2016-06-21T16:13:14.52-0400 [APP/0] OUT 16: DEBUG PoolingHttpClientConnectionManager - Connection request: [route: {s}->https://api.run.pivotal.io:443][total kept alive: 0; route allocated: 0 of 5; total allocated: 0 of 10]
2016-06-21T16:13:14.54-0400 [APP/0] OUT 16: DEBUG PoolingHttpClientConnectionManager - Connection leased: [id: 0][route: {s}->https://api.run.pivotal.io:443][total kept alive: 0; route allocated: 1 of 5; total allocated: 1 of 10]
2016-06-21T16:13:14.54-0400 [APP/0] OUT 16: DEBUG MainClientExec - Opening connection {s}->https://api.run.pivotal.io:443
2016-06-21T16:13:14.54-0400 [APP/0] OUT 16: DEBUG DefaultHttpClientConnectionOperator - Connecting to api.run.pivotal.io/52.72.101.87:443
2016-06-21T16:13:14.54-0400 [APP/0] OUT 16: DEBUG SSLConnectionSocketFactory - Connecting socket to api.run.pivotal.io/52.72.101.87:443 with timeout 0
2016-06-21T16:13:14.70-0400 [HEALTH/0] OUT healthcheck failed
2016-06-21T16:13:14.70-0400 [HEALTH/0] OUT Exit status 1
2016-06-21T16:13:15.74-0400 [HEALTH/0] OUT healthcheck failed
这是我在Github中的user-service应用程序的链接。
以下是 application.yml 文件的内容:
# Spring properties
spring:
application:
name: ${vcap.application.name}
cloud:
services:
registrationMethod: route
---
spring:
profiles: dev
security:
basic:
enabled: false
# Logging
logging:
level:
ROOT: INFO
org.springframework.web: DEBUG
这是我的 manifest.yml 文件:
instances: 1
memory: 1024M
applications:
- name: user-service
services:
- my-eureka-server
env:
SPRING_PROFILES_ACTIVE: dev
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>com.verizon.microservice</groupId>
<artifactId>microservice-user-service</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>microservice-user-service</name>
<description>Demo project Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.5.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Brixton.SR1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-cloudfoundry-discovery</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter</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-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>spring-release</id>
<url>https://repo.spring.io/libs-release</url>
</repository>
</repositories>
</project>
任何人都可以帮助我,我错过了什么。我试图在任何地方找到解决方案,但无法得到它。
提前致谢
答案 0 :(得分:0)
我现在能够解决这个问题。我在application.yml文件中缺少CloudFoundry PORT环境变量。
这link解释了这个问题。
现在, application.yml 文件看起来像belwo:
# HTTP Server
server:
port: ${vcap.PORT}
# Spring properties
spring:
application:
name: ${vcap.application.name}
cloud:
services:
registrationMethod: route
---
spring:
profiles: dev
---
security:
basic:
enabled: false
---
# Logging
logging:
level:
ROOT: INFO
org.springframework.web: INFO
现在,我的应用程序已在Cloud Foundry上运行。我可以使用URL访问服务。
答案 1 :(得分:0)
它与POM配置无关。
您可以在推送此应用时设置DOMAIN和HOST名称吗?以下错误有健康检查失败是由于:
Register host [localhost] at domain [null] for service [StandardService[Tomcat]]