【问题标题】:Couldn't find that process type (web) when deploying spring boot application部署 Spring Boot 应用程序时找不到该进程类型(Web)
【发布时间】:2021-04-03 21:16:11
【问题描述】:

我有一个在本地运行的spring boot 应用程序。我想在heroku 上部署。我按照here 的说明进行操作,但它不起作用,我收到"No web processes running" 错误。 按照建议的解决方案,我尝试了>heroku ps:scale web=1,但我得到了Couldn't find that process type 错误。 然后,我尝试了以下命令:

heroku buildpacks:clear

heroku buildpacks:add heroku/java

git commit --allow-empty -m "Adjust buildpacks on Heroku"

git push heroku master

但问题仍然存在。 如果有帮助,这是我的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.tests4geeks.tutorials</groupId>
    <artifactId>mongo-tutorial</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>

    <name>mongo-tutorial</name>
    <description>Demo project for Spring Boot</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.3.3.RELEASE</version>
        <relativePath />
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <java.version>1.8</java.version>
        <thymeleaf.version>3.0.11.RELEASE</thymeleaf.version>
    </properties>

    <dependencies>
    
     <dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-tomcat</artifactId>
  <scope>provided</scope>
 </dependency>
    
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-mongodb</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</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>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-couchbase</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>

        <dependency>
            <groupId>nz.net.ultraq.thymeleaf</groupId>
            <artifactId>thymeleaf-layout-dialect</artifactId>
        </dependency>

        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>bootstrap</artifactId>
            <version>3.3.7</version>
        </dependency>
        
<dependency>
    <groupId>commons-net</groupId>
    <artifactId>commons-net</artifactId>
    <version>3.6</version>
</dependency>
        
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-validation</artifactId>
</dependency>
        
        <dependency>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-mail</artifactId>
</dependency>

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-data-mongodb-reactive</artifactId>
</dependency>

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
    
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

build的输出:

Enumerating objects: 277, done.
Counting objects: 100% (277/277), done.
Delta compression using up to 8 threads
Compressing objects: 100% (259/259), done.
Writing objects: 100% (277/277), 157.87 MiB | 1.29 MiB/s, done.
Total 277 (delta 22), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Java app detected
remote: -----> Installing JDK 1.8... done
remote: -----> Installing Maven 3.6.2... done
remote: -----> Executing Maven
remote:        $ mvn -DskipTests clean dependency:list install
remote:        [INFO] Scanning for projects...
remote:        [INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-starter-parent/2.3.3.RELEASE/spring-boot-starter-parent-2.3.3.RELEASE.pom
remote:        [INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-starter-parent/2.3.3.RELEASE/spring-boot-starter-parent-2.3.3.RELEASE.pom (8.6 kB at 13 kB/s)
remote:        [INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-dependencies/2.3.3.RELEASE/spring-boot-dependencies-2.3.3.RELEASE.pom
remote:        [INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-dependencies/2.3.3.RELEASE/spring-boot-dependencies-2.3.3.RELEASE.pom (122 kB at 1.4 MB/s)
remote:        [INFO] Downloading from central: https://repo.maven.apache.org/maven2/com/datastax/oss/java-driver-bom/4.6.1/java-driver-bom-4.6.1.pom
remote:        [INFO] Downloaded from central: https://repo.maven.apache.org/maven2/com/datastax/oss/java-driver-bom/4.6.1/java-driver-bom-4.6.1.pom (3.8 kB at 251 kB/s)

remote:        [INFO] Installing /tmp/build_84b248db/target/mongo-tutorial-0.0.1-SNAPSHOT.war to /tmp/codon/tmp/cache/.m2/repository/com/tests4geeks/tutorials/mongo-tutorial/0.0.1-SNAPSHOT/mongo-tutorial-0.0.1-SNAPSHOT.war
remote:        [INFO] Installing /tmp/build_84b248db/pom.xml to /tmp/codon/tmp/cache/.m2/repository/com/tests4geeks/tutorials/mongo-tutorial/0.0.1-SNAPSHOT/mongo-tutorial-0.0.1-SNAPSHOT.pom
remote:        [INFO] ------------------------------------------------------------------------
remote:        [INFO] BUILD SUCCESS
remote:        [INFO] ------------------------------------------------------------------------
remote:        [INFO] Total time:  26.956 s
remote:        [INFO] Finished at: 2020-12-26T20:53:46Z
remote:        [INFO] ------------------------------------------------------------------------
remote: -----> Discovering process types
remote:        Procfile declares types -> (none)
remote:
remote: -----> Compressing...
remote:        Done: 211.1M
remote: -----> Launching...
remote:        Released v3
remote:        https://hidden-coast-44319.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy... done.
To https://git.heroku.com/hidden-coast-44319.git
 * [new branch]      master -> master

【问题讨论】:

  • 这与您的构建包无关,我认为您的 pom.xml 也不相关(尽管我不是 Java 开发人员)。你有Procfile 吗?它包含什么?我假设由于您尝试使用heroku/java,因此您没有使用 Docker 进行部署?
  • @Chris 我没有使用 Docker。你说得对。关于Procfile,我没有,似乎没有必要。在我分享的链接 (devcenter.heroku.com/articles/…) 中,应用程序已正确部署,无需 Procfile。
  • 如果您没有Procfile,我不清楚如何映射流程类型。请edit您的问题向我们展示您推送时的完整构建输出。
  • @Chris 我也尝试使用包含“web: java -Dserver.port=$PORT $JAVA_OPTS -jar target/*.jar”的 Procfile,但它没有帮助,我得到了另一个错误:错误:无法访问 jarfile 目标/*.jar
  • 好吧,那是另一个问题。请edit 你的问题显示我之前问过的构建输出,或者就Procfile 的问题提出一个 问题。

标签: java spring spring-boot heroku deployment


【解决方案1】:

我可以通过添加包含以下文本的 Procfile 来解决它:

web: java -jar target/mongo-tutorial-1.0.jar

并从pom 文件中删除以下行:

<packaging>war</packaging>

【讨论】:

    猜你喜欢
    • 2020-05-08
    • 2017-10-16
    • 2022-12-17
    • 2017-09-30
    • 2018-09-12
    • 1970-01-01
    • 2019-05-06
    • 2021-07-25
    • 1970-01-01
    相关资源
    最近更新 更多