我正在尝试将一个简单的 SpringMVC REST API 部署到 Heroku - 我在 github 上有示例代码。当我部署到 Heroku 时,该应用程序无法运行 - 这是我在 Heroku 的日志文件中看到的内容:
2016-11-21T00:28:28.965526+00:00 app[web.1]: 在 org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:138)
2016-11-21T00:28:28.965587 + 00:00应用程序[web.1]:在org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:121)
2016-11-21T00:28:28.965642 + 00:00应用程序[web.1]:在org.springframework.boot.context.event.EventPublishingRunListener.started(EventPublishingRunListener.java:63)
2016-11-21T00:28:28.965701 + 00:00应用程序[web.1]:在org.springframework.boot.SpringApplicationRunListeners.started(SpringApplicationRunListeners.java:48)
2016-11-21T00:28:28.965762 + 00:00应用程序[web.1]:在org.springframework.boot.SpringApplication.run(SpringApplication.java:304)
2016-11-21T00:28:28.965804 + 00:00应用程序[web.1]:在org.springframework.boot.SpringApplication.run(SpringApplication.java:1186)
2016-11-21T00:28:28.965865 + 00:00应用程序[web.1]:在org.springframework.boot.SpringApplication.run(SpringApplication.java:1175)
2016-11-21T00:28:28.965926 + 00:00应用程序[web.1]:在com.jkerak.TodoApiApplication.main(TodoApiApplication.java:9)
2016-11-21T00:28:28.965989+00:00 应用程序[web.1]: ... 8 更多
2016-11-21T00:28:29.096742+00:00 heroku[web.1]:状态从开始变为崩溃
2016-11-21T00:28:29.081552+00:00 heroku[web.1]:进程已退出,状态为 1
2016-11-21T00:51:54.625237 + 00:00 heroku [路由器]:at =错误代码= H10 desc =“应用程序崩溃”方法= GET路径=“/”主机= jkerak-todoapi.herokuapp.com request_id = 73c76e69 -2084-436f-b829-dd533562d13a fwd="73.30.84.74"dyno=连接=服务=状态=503字节=
我在本地运行应用程序没有问题。
有没有地方可以获取有关 Heroku 问题的更多信息?我正在使用“Github 部署”管道部署应用程序。
最佳答案
您发布的日志已被截断(您可以通过运行 heroku logs -n 2000 -a youapp
来获取更多日志)。但是使用Github上的代码,发现错误:
Caused by: java.lang.IllegalArgumentException: LoggerFactory is not a Logback LoggerContext but Logback is on the classpath. Either remove Logback or the competing implementation (class org.slf4j.impl.SimpleLoggerFactory loaded from jar:file:/app/target/todoApi-0.0.1-SNAPSHOT.jar!/BOOT-INF/lib/slf4j-simple-1.7.21.jar!/). If you are using WebLogic you will need to add 'org.slf4j' to prefer-application-packages in WEB-INF/weblogic.xml Object of class [org.slf4j.impl.SimpleLoggerFactory] must be an instance of class ch.qos.logback.classic.LoggerContext
因此您的类路径上存在错误。我怀疑这不会在本地发生,因为类路径顺序是不确定的。
尝试从依赖项中删除 slf4j-simple-1.7.21
。您可以通过更改 swagger-codegen 依赖项来做到这一点:
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-codegen</artifactId>
<version>2.2.1</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</exclusion>
</exclusions>
</dependency>
关于java - Heroku 上的 Spring 启动 - H10 "app crash",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40711333/