I have been facing issue with deploying a spring boot application in Pivotal Cloud Web Foundry. I keep getting this error:
2018-01-29T22:18:50.84-0500 [HEALTH/0] ERR Failed to make HTTP request to '/' on port 8080: connection refused
2018-01-29T22:18:50.84-0500 [CELL/0] ERR Timed out after 15s: health check never passed.
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.stargate.transferfund</groupId>
<artifactId>TransferFund</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>TransferFund</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.9.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<startClass>org.springframework.boot.SpringApplication</startClass>
<maven.test.skip>true</maven.test.skip>
</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-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- marked the embedded servlet container as provided -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<!-- JMS related dependencies -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-activemq</artifactId>
<version>1.5.9.RELEASE</version>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-broker</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
Controller class
@Controller
public class TestController {
@RequestMapping(value="/", method=RequestMethod.GET)
public ResponseEntity sayHello() {
return new ResponseEntity("Hello world", HttpStatus.ACCEPTED);
}
}
Application
@SpringBootApplication
public class TransferFundApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(TransferFundApplication.class, args);
}
/**
* Used when run as WAR
*/
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(TransferFundApplication.class);
}
}
manifest.yml
---
applications:
- name: target
path: target/TransferFund-0.0.1-SNAPSHOT.jar
health-check-type: http
buildpack: https://github.com/cloudfoundry/java-buildpack.git
It looks like the port 8080 is not detected for some reasons. I have tried changing the health-check-type to process and port. When I change it to process it works but the endpoints are not longer accessible. Need some help in solving the issue
Please try after adding the following dependency of actuator :
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
Also add the following to the manifest.yml :
health-check-http-endpoint: /info
health-check-type: http
I think this should solve the problem.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.