本文介绍了无法在Cloud Foundry上部署helloworld spring-boot应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用cf push helloworld-api命令在Cloud Foundry上部署简单的helloworld SpringBoot应用程序时遇到以下错误.

Getting following error while deploy a simple helloworld SpringBoot app on Cloud Foundry using cf push helloworld-api command.

注意:我没有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 !";
    }

}

推荐答案

登台的输出表明,所有detect脚本都针对所有已安装的buildpack(包括Java buildpack)运行,但未检测到任何能够运行您的应用.

The output from staging is indicating that all of the detect scripts ran for all of the installed buildpack, including the Java buildpack, but did not detect that any were able to run your app.

问题出在您的推送命令cf push helloworld-api上.由于要部署Java应用程序,因此需要指定-p path/to/my.jar.您需要这样做,以便部署已编译的应用程序,而不是源代码.如果没有路径,cf push默认会推送当前目录,这可能是我们的源代码. Java buildpack只知道如何部署已编译的应用程序,而不能构建和部署您的源代码.

The problem is with your push command, cf push helloworld-api. Since you're deploying a Java app, you need to specify -p path/to/my.jar. You need this so that your compiled application is deployed, not the source code. Without a path, cf push defaults to pushing the current directory which is probably our source code. The Java buildpack only knows how to deploy compiled apps, it cannot build and deploy your source code.

这篇关于无法在Cloud Foundry上部署helloworld spring-boot应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 19:00