【发布时间】:2020-06-03 13:44:23
【问题描述】:
我目前正在部署一个应用程序,但由于某种原因它似乎无法完美运行。
在编码时,我正在使用易于配置的 Intellij Spring Boot 运行程序运行/调试项目。
由于我需要在 Tomcat 服务器上进行部署,因此我尝试先在 Intellij 中设置一个 Tomcat Server Runner,然后再从我的 Tomcat 服务器直接运行我的战争。
问题是:运行似乎无法正常工作。事实上,即使部署没有返回任何错误,应用程序也没有完全启动。
这是一个 Spring Boot 运行器输出:
2020-02-19 11:50:18.373 DEBUG 1192 --- [ restartedMain] com.myapp.Application : Running with Spring Boot v2.2.4.RELEASE, Spring v5.2.3.RELEASE
2020-02-19 11:50:18.374 INFO 1192 --- [ restartedMain] com.myapp.Application : No active profile set, falling back to default profiles: default
2020-02-19 11:50:18.421 INFO 1192 --- [ restartedMain] o.s.b.devtools.restart.ChangeableUrls : The Class-Path manifest attribute in C:\Users\user\.m2\repository\org\glassfish\jaxb\jaxb-runtime\2.3.2\jaxb-runtime-2.3.2.jar referenced one or more files that do not exist: file:/C:/Users/user/.m2/repository/org/glassfish/jaxb/jaxb-runtime/2.3.2/jakarta.xml.bind-api-2.3.2.jar,file:/C:/Users/user/.m2/repository/org/glassfish/jaxb/jaxb-runtime/2.3.2/txw2-2.3.2.jar,file:/C:/Users/user/.m2/repository/org/glassfish/jaxb/jaxb-runtime/2.3.2/istack-commons-runtime-3.0.8.jar,file:/C:/Users/user/.m2/repository/org/glassfish/jaxb/jaxb-runtime/2.3.2/stax-ex-1.8.1.jar,file:/C:/Users/user/.m2/repository/org/glassfish/jaxb/jaxb-runtime/2.3.2/FastInfoset-1.2.16.jar,file:/C:/Users/user/.m2/repository/org/glassfish/jaxb/jaxb-runtime/2.3.2/jakarta.activation-api-1.2.1.jar
2020-02-19 11:50:18.422 INFO 1192 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2020-02-19 11:50:18.422 INFO 1192 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2020-02-19 11:50:19.223 INFO 1192 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2020-02-19 11:50:19.288 INFO 1192 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 57ms. Found 1 JPA repository interfaces.
2020-02-19 11:50:19.807 INFO 1192 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-02-19 11:50:20.115 INFO 1192 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8081 (http)
2020-02-19 11:50:20.125 INFO 1192 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-02-19 11:50:20.125 INFO 1192 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.30]
2020-02-19 11:50:20.233 INFO 1192 --- [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
etc.
2020-02-19 11:50:24.396 INFO 1192 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2020-02-19 11:50:24.399 INFO 1192 --- [ restartedMain] com.myapp.Application : Started Application in 6.531 seconds (JVM running for 7.815)
还有一个 Tomcat 运行器输出:
2020-02-19 12:14:15.753 INFO 4436 --- [on(3)-127.0.0.1] com.myapp.Application : Starting Application on UO with PID 4436 (C:\App\apache-tomcat-8.0.47\webapps\server_war\WEB-INF\classes started by user in C:\App\apache-tomcat-8.0.47\bin)
2020-02-19 12:14:15.757 DEBUG 4436 --- [on(3)-127.0.0.1] com.myapp.Application : Running with Spring Boot v2.2.4.RELEASE, Spring v5.2.3.RELEASE
2020-02-19 12:14:15.760 INFO 4436 --- [on(3)-127.0.0.1] com.myapp.Application : No active profile set, falling back to default profiles: default
2020-02-19 12:14:15.937 INFO 4436 --- [on(3)-127.0.0.1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 113 ms
2020-02-19 12:14:15.994 INFO 4436 --- [on(3)-127.0.0.1] com.myapp.Application : Started Application in 1.045 seconds (JVM running for 7.228)
[2020-02-19 12:14:16,029] Artifact server:war: Artifact is deployed successfully
[2020-02-19 12:14:16,029] Artifact server:war: Deploy took 5,204 milliseconds
如您所见,Spring 已正确启动,但似乎并未执行所有启动任务。
我的 pom 中已经提供了 spring-boot-starter-tomcat,这是我的 Application.class:
@SpringBootApplication public class Application extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@Override protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(Application.class);
}
}
我的问题是:我是否遗漏了配置中的某些内容?如何使用具有多个配置文件的 Tomcat 正确运行所有内容(我目前在运行器中使用 VM 选项)?
【问题讨论】:
-
您似乎只查看了日志记录。您是否尝试过创建一个简单的 REST 端点或可以从浏览器获取的东西以查看它是否有任何作用?
-
是的,我得到了一个 Apache 404 返回...
标签: java spring-boot tomcat deployment spring-profiles