java - 使用 'webapp-runner' 运行 Spring boot 应用程序后,它停止在一行 "INFO: Starting ProtocolHandler ["http-nio-808 0"]"

标签 java spring spring-boot tomcat heroku

我需要将应用程序部署到 heroku,它是使用 Spring Boot 创建的,因此我添加了一个 webapp-runner.jar 插件,现在它无法在 Heroku 上运行,而在本地机器上我如果我使用 webapp-runner.jar 从 cmd 运行它,我会遇到同样的问题。

现在我使用的是 runner 9.0.24.0 版本,之前我尝试在版本 8 中运行它...

那是我在 pom.xml 中的插件

<plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <goals><goal>copy</goal></goals>
            <configuration>
              <artifactItems>
                <artifactItem>
                  <groupId>com.github.jsimone</groupId>
                  <artifactId>webapp-runner</artifactId>
                  <version>9.0.24.0</version>
                  <destFileName>webapp-runner.jar</destFileName>
                </artifactItem>
              </artifactItems>
            </configuration>
          </execution>
        </executions>
      </plugin>

这是我的Procfile

web: java $JAVA_OPTS -jar target/dependency/webapp-runner.jar --port $PORT target/*.war

这是我从 cmd 得到的日志

авг 29, 2019 11:09:47 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-nio-8080"]
авг 29, 2019 11:09:48 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service [Tomcat]
авг 29, 2019 11:09:48 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet engine: [Apache Tomcat/9.0.24]
авг 29, 2019 11:09:49 PM org.apache.catalina.startup.ContextConfig getDefaultWebXmlFragment
INFO: No global web.xml found
авг 29, 2019 11:10:04 PM org.apache.catalina.core.ApplicationContext log
INFO: 1 Spring WebApplicationInitializers detected on classpath
авг 29, 2019 11:10:05 PM org.apache.jasper.servlet.TldScanner scanJars
INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
авг 29, 2019 11:10:05 PM org.apache.catalina.util.SessionIdGeneratorBase createSecureRandom
WARNING: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [241] milliseconds.
авг 29, 2019 11:10:05 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-nio-8080"]

它应该像在本地机器和 Heroku 中一样使用来自 Procfile 的命令运行它。我该如何解决该问题?

最佳答案

这篇文章过去对我帮助很大,可能对你也有用。

  • 将目录切换到 Tomcat 的安装位置,然后转到 bin
  • 使用您喜欢的任何编辑器(如 nanovim)打开 catalina.sh 文件。
  • 寻找 JAVA_OPTS 并添加这一行:

-Djava.security.egd=file:/dev/./urandom

来源:https://geekflare.com/tomcat-stuck-at-startup/

关于java - 使用 'webapp-runner' 运行 Spring boot 应用程序后,它停止在一行 "INFO: Starting ProtocolHandler ["http-nio-808 0"]",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57717335/

相关文章:

java - 图片检索速度慢

java - 访问应用程序外部文件夹文件以在 Play Framework 2.6.x 模板中渲染的方式是什么?

java - 在非实体 java bean 中映射多个 hibernate 实体

ElasticSearch 2.0 Java API : java. lang.ClassNotFoundException : org. elasticsearch.common.settings.ImmutableSettings$Builder

java - 在 Weblogic 12c 中部署具有 com.fasterxml 依赖项的 Spring Boot 应用程序

Javafx如何模拟Tab上的右键单击事件

java - 当我调用它时,下面方法的参数可以是什么

java - 从spring 2.5开始如何调用restful服务

java - 如何在 Spring Boot Security 中启用或禁用用户

spring-boot - 使用 mvn spring-boot :run "A child container fail to start" 出错