使用SpringBoot
命令在Cloud Foundry
上部署简单的helloworld cf push helloworld-api
应用时出现以下错误。
注意:我没有manifest.yml
文件
错误日志:
Staging app and tracing logs...
Downloading binary_buildpack...
Downloading python_buildpack...
Downloading go_buildpack...
Downloading dotnet_core_buildpack...
Downloading php_buildpack...
Downloaded binary_buildpack
Downloading hwc_buildpack...
Downloaded go_buildpack
Downloading staticfile_buildpack...
Downloaded dotnet_core_buildpack
Downloading dotnet_core_buildpack_beta...
Downloaded dotnet_core_buildpack_beta
Downloading java_buildpack...
Downloaded hwc_buildpack
Downloading ruby_buildpack...
Downloaded staticfile_buildpack
Downloading nodejs_buildpack...
Downloaded java_buildpack
Downloaded python_buildpack
Downloaded ruby_buildpack
Downloaded nodejs_buildpack
Downloaded php_buildpack
Cell 501d8bad-6db9-4f37-bcbb-bf678aeaa558 creating container for instance ef6baefc-b5e2-4bb4-9c5e-1711b4b8eb5c
Cell 501d8bad-6db9-4f37-bcbb-bf678aeaa558 successfully created container for instance ef6baefc-b5e2-4bb4-9c5e-1711b4b8eb5c
Downloading app package...
Downloaded app package (85.1K)
None of the buildpacks detected a compatible application
Exit status 222
Cell 501d8bad-6db9-4f37-bcbb-bf678aeaa558 stopping instance ef6baefc-b5e2-4bb4-9c5e-1711b4b8eb5c
Cell 501d8bad-6db9-4f37-bcbb-bf678aeaa558 destroying container for instance ef6baefc-b5e2-4bb4-9c5e-1711b4b8eb5c
Cell 501d8bad-6db9-4f37-bcbb-bf678aeaa558 successfully destroyed container for instance ef6baefc-b5e2-4bb4-9c5e-1711b4b8eb5c
Error staging application: An app was not successfully detected by any available buildpack
TIP: Use 'cf buildpacks' to see a list of supported buildpacks.
FAILED
的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.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>helloworld</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.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>
</properties>
<dependencies>
<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>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
HelloWorldApplication.java
@SpringBootApplication
@RestController
public class HelloworldApplication {
public static void main(String[] args) {
SpringApplication.run(HelloworldApplication.class, args);
}
@RequestMapping(path = "/", method = RequestMethod.GET)
public String greet() {
return "Hello World !";
}
}
答案 0 :(得分:2)
staging的输出表明所有已安装的buildpack都运行了所有b = (("ben","4994"),("dan","2993"),("Hans",100),("Frank",20.5))
print(b[1])
脚本,包括Java buildpack,但没有检测到任何能够运行你的应用程序。
问题在于您的推送命令detect
。由于您正在部署Java应用程序,因此需要指定cf push helloworld-api
。您需要这样才能部署已编译的应用程序,而不是源代码。没有路径,-p path/to/my.jar
默认推送当前目录,这可能是我们的源代码。 Java buildpack只知道如何部署编译的应用程序,它无法构建和部署源代码。
答案 1 :(得分:0)
我遇到了同样的问题,您需要正确给出jar的路径。我的jar已在目标文件夹下创建,因此我不得不将命令更改为
cf push springpcf -p target **target**\springpcf-0.0.1-SNAPSHOT.jar