Tomcat上的Spring Boot War部署不起作用
Posted
技术标签:
【中文标题】Tomcat上的Spring Boot War部署不起作用【英文标题】:Spring Boot War Deployment on Tomcat not working 【发布时间】:2020-10-23 00:40:36 【问题描述】:我部署了一个WAR格式的springboot应用包。但我没有在控制台中看到与 spring 相关的日志。另外,我看不到应用程序正在运行。可能的原因是什么?我附上tomcat日志。提前致谢
2020-07-02 17:22:17.744 INFO 17952 --- [ost-startStop-1] c.s.narayaneeyam.ServletInitializer : Starting ServletInitializer v0.0.1-SNAPSHOT on DESKTOP-PB6GB90 with PID 17952 (D:\Tomcat\apache-tomcat-8.5.56-windows-x64\apache-tomcat-8.5.56\webapps\narayaneeyam-0.0.1-SNAPSHOT\WEB-INF\classes started by sachi in D:\Tomcat\apache-tomcat-8.5.56-windows-x64\apache-tomcat-8.5.56\bin)
2020-07-02 17:22:17.754 INFO 17952 --- [ost-startStop-1] c.s.narayaneeyam.ServletInitializer : No active profile set, falling back to default profiles: default
2020-07-02 17:22:20.982 INFO 17952 --- [ost-startStop-1] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFERRED mode.
2020-07-02 17:22:21.248 INFO 17952 --- [ost-startStop-1] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 227ms. Found 4 JPA repository interfaces.
2020-07-02 17:22:22.688 INFO 17952 --- [ost-startStop-1] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 4795 ms
2020-07-02 17:22:23.760 INFO 17952 --- [ost-startStop-1] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2020-07-02 17:22:23.944 INFO 17952 --- [ task-1] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2020-07-02 17:22:24.042 WARN 17952 --- [ost-startStop-1] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2020-07-02 17:22:24.172 INFO 17952 --- [ost-startStop-1] .s.s.UserDetailsServiceAutoConfiguration :
Using generated security password: 3c2c7634-78d3-4015-ab8e-c9a6c99c4b3b
2020-07-02 17:22:24.288 INFO 17952 --- [ task-1] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.4.17.Final
2020-07-02 17:22:25.162 INFO 17952 --- [ task-1] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations 5.1.0.Final
2020-07-02 17:22:25.745 INFO 17952 --- [ task-1] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2020-07-02 17:22:26.474 INFO 17952 --- [ task-1] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2020-07-02 17:22:26.573 INFO 17952 --- [ task-1] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.mysql8Dialect
2020-07-02 17:22:26.621 INFO 17952 --- [ost-startStop-1] o.s.s.web.DefaultSecurityFilterChain : Creating filter chain: any request, [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@2e78fc6, org.springframework.security.web.context.SecurityContextPersistenceFilter@5adbbfc, org.springframework.security.web.header.HeaderWriterFilter@5e4ef05f, org.springframework.security.web.csrf.CsrfFilter@6f946b3c, org.springframework.security.web.authentication.logout.LogoutFilter@61bb46d, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter@5dcf9e1a, org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter@5a5ac80e, org.springframework.security.web.authentication.ui.DefaultLogoutPageGeneratingFilter@4fb155f8, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@54779eb2, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@39715673, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@6708ba7c, org.springframework.security.web.session.SessionManagementFilter@53fa3c7e, org.springframework.security.web.access.ExceptionTranslationFilter@e50c54, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@50b9a845]
2020-07-02 17:22:29.827 INFO 17952 --- [ task-1] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2020-07-02 17:22:29.865 INFO 17952 --- [ task-1] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2020-07-02 17:22:29.994 INFO 17952 --- [ost-startStop-1] o.s.b.a.e.web.EndpointLinksResolver : Exposing 2 endpoint(s) beneath base path '/actuator'
2020-07-02 17:22:30.060 INFO 17952 --- [ost-startStop-1] DeferredRepositoryInitializationListener : Triggering deferred initialization of Spring Data repositoriesà
2020-07-02 17:22:31.170 INFO 17952 --- [ost-startStop-1] DeferredRepositoryInitializationListener : Spring Data repositories initialized!
2020-07-02 17:22:31.187 INFO 17952 --- [ost-startStop-1] c.s.narayaneeyam.ServletInitializer : Started ServletInitializer in 14.858 seconds (JVM running for 42.474)
02-Jul-2020 17:22:31.264 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive [D:\Tomcat\apache-tomcat-8.5.56-windows-x64\apache-tomcat-8.5.56\webapps\narayaneeyam-0.0.1-SNAPSHOT.war] has finished in [41,103] ms
02-Jul-2020 17:22:31.283 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [D:\Tomcat\apache-tomcat-8.5.56-windows-x64\apache-tomcat-8.5.56\webapps\docs]
02-Jul-2020 17:22:31.316 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [D:\Tomcat\apache-tomcat-8.5.56-windows-x64\apache-tomcat-8.5.56\webapps\docs] has finished in [33] ms
02-Jul-2020 17:22:31.316 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [D:\Tomcat\apache-tomcat-8.5.56-windows-x64\apache-tomcat-8.5.56\webapps\examples]
02-Jul-2020 17:22:32.114 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [D:\Tomcat\apache-tomcat-8.5.56-windows-x64\apache-tomcat-8.5.56\webapps\examples] has finished in [798] ms
02-Jul-2020 17:22:32.115 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [D:\Tomcat\apache-tomcat-8.5.56-windows-x64\apache-tomcat-8.5.56\webapps\host-manager]
02-Jul-2020 17:22:32.155 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [D:\Tomcat\apache-tomcat-8.5.56-windows-x64\apache-tomcat-8.5.56\webapps\host-manager] has finished in [40] ms
02-Jul-2020 17:22:32.156 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [D:\Tomcat\apache-tomcat-8.5.56-windows-x64\apache-tomcat-8.5.56\webapps\manager]
02-Jul-2020 17:22:32.201 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [D:\Tomcat\apache-tomcat-8.5.56-windows-x64\apache-tomcat-8.5.56\webapps\manager] has finished in [45] ms
02-Jul-2020 17:22:32.201 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [D:\Tomcat\apache-tomcat-8.5.56-windows-x64\apache-tomcat-8.5.56\webapps\ROOT]
02-Jul-2020 17:22:32.236 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [D:\Tomcat\apache-tomcat-8.5.56-windows-x64\apache-tomcat-8.5.56\webapps\ROOT] has finished in [35] ms
02-Jul-2020 17:22:32.242 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
02-Jul-2020 17:22:32.257 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 42167 ms
【问题讨论】:
日志就在那里,用户生成等都来自您的应用程序。 【参考方案1】:这些都是spring的日志:
2020-07-02 17:22:20.982 INFO 17952 --- [ost-startStop-1] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFERRED mode.
2020-07-02 17:22:21.248 INFO 17952 --- [ost-startStop-1] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 227ms. Found 4 JPA repository interfaces.
2020-07-02 17:22:26.621 INFO 17952 --- [ost-startStop-1] o.s.s.web.DefaultSecurityFilterChain : Creating filter chain: any request, [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@2e78fc6, org.springframework.security.web.context.SecurityContextPersistenceFilter@5adbbfc, org.springframework.security.web.header.HeaderWriterFilter@5e4ef05f, org.springframework.security.web.csrf.CsrfFilter@6f946b3c, org.springframework.security.web.authentication.logout.LogoutFilter@61bb46d, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter@5dcf9e1a, org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter@5a5ac80e, org.springframework.security.web.authentication.ui.DefaultLogoutPageGeneratingFilter@4fb155f8, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@54779eb2, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@39715673, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@6708ba7c, org.springframework.security.web.session.SessionManagementFilter@53fa3c7e, org.springframework.security.web.access.ExceptionTranslationFilter@e50c54, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@50b9a845]
2020-07-02 17:22:29.994 INFO 17952 --- [ost-startStop-1] o.s.b.a.e.web.EndpointLinksResolver : Exposing 2 endpoint(s) beneath base path '/actuator'
o.s.d.r.c 表示 org.springframework.data.repository.config os.s.web 表示 org.springframework.security.web
所以这些都是 Spring 类的日志。
如果想查看更多spring日志,只需在application.yaml中设置日志级别为debug即可:
logging:
level:
org.springframework.boot: debug
【讨论】:
先生,我搞定了,谢谢。当我输入 localhost:8080/appname 时,我可以看到 webapp。然后我尝试将战争文件部署到 Elastic Beanstalk。我收到 404。可能是什么原因?日志看起来非常相似。但是当我将 BeanStalk 端点复制到 URL 栏中时,我得到 404 @SachinTitus 这是一个不同的问题,我不是上帝,无法弄清楚为什么它在没有看到任何日志的情况下无法工作。请随时发布一个包含所有详细信息的新问题。我会尽力解决。如果 Tomcat 的问题得到解决,请通过接受来结束这个问题。以上是关于Tomcat上的Spring Boot War部署不起作用的主要内容,如果未能解决你的问题,请参考以下文章
Spring Boot:在 Tomcat 7 上部署 WAR