Spring 在 CloudFoundry 上使用 Eureka 启动应用程序健康检查失败问题
Spring Boot Application with Eureka on CloudFoundry healthcheck failed issue
我有一个 Spring 引导应用程序(独立的 jar 文件),我试图将其部署到 CloudFoundry 上。我在 CloudFoundry 上创建了一个 Service Registry 实例,并尝试使用 CloudFoundry CLI 推送 (cf push -p target\microservice-user-service-0.0.1-SNAPSHOT.jar)
我的应用程序 (user-service)。
应用上传成功,服务绑定成功。一旦启动,它会给出健康检查失败的问题
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 申请的 link。
以下是我的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>
任何人都可以帮助我解决我所缺少的问题。到处找解决办法,就是找不到。
提前致谢
我现在可以解决这个问题。我在 application.yml 文件中缺少 CloudFoundry PORT 环境变量。
这link解释了这个问题。
现在,application.yml 文件如下所示:
# 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 访问服务。
与POM配置无关
能否在推送此应用时设置域和主机名?以下错误 had health check is failure 是由于此:
Register host [localhost] at domain [null] for service [StandardService[Tomcat]]
我有一个 Spring 引导应用程序(独立的 jar 文件),我试图将其部署到 CloudFoundry 上。我在 CloudFoundry 上创建了一个 Service Registry 实例,并尝试使用 CloudFoundry CLI 推送 (cf push -p target\microservice-user-service-0.0.1-SNAPSHOT.jar)
我的应用程序 (user-service)。
应用上传成功,服务绑定成功。一旦启动,它会给出健康检查失败的问题
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 申请的 link。
以下是我的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>
任何人都可以帮助我解决我所缺少的问题。到处找解决办法,就是找不到。
提前致谢
我现在可以解决这个问题。我在 application.yml 文件中缺少 CloudFoundry PORT 环境变量。
这link解释了这个问题。
现在,application.yml 文件如下所示:
# 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 访问服务。
与POM配置无关
能否在推送此应用时设置域和主机名?以下错误 had health check is failure 是由于此:
Register host [localhost] at domain [null] for service [StandardService[Tomcat]]