使用 Maven 构建的 Java Spring Boot Web App(hello world)

我正在尝试使用 maven 运行一个新的 Java Spring Web 应用程序构建并部署到 Tomcat。我在 SO 上发现了大量带有类似错误消息的问题,但没有任何答案有帮助。这是一个课堂作业,但是我什至无法启动,因为我无法启动我的 tomcat 服务器。这是我的日志:


 :: Spring Boot ::        (v2.0.3.RELEASE)


2018-10-13 22:30:45.669  INFO 14840 --- [           main] com.store.app.Application                : 

2018-10-13 22:30:45.672  INFO 14840 --- [           main] com.store.app.Application                : No active profile set, falling back to default profiles: default

2018-10-13 22:30:45.778  INFO 14840 --- [           main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@4fe767f3: startup date [Sat Oct 13 22:30:45 EDT 2018]; root of context hierarchy

2018-10-13 22:30:47.046  INFO 14840 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)

2018-10-13 22:30:47.062  INFO 14840 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]

2018-10-13 22:30:47.063  INFO 14840 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/9.0.12

pom.xml 中没有 tomcat 版本的缩短错误:


ERROR 15272 --- [cat-startStop-1] org.apache.catalina.core.ContainerBase   : A child container failed during start


java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].TomcatEmbeddedContext[]]

    at java.util.concurrent.FutureTask.report(FutureTask.java:122) [na:1.8.0_161]

    at java.util.concurrent.FutureTask.get(FutureTask.java:192) [na:1.8.0_161]

    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:941) ~[tomcat-embed-core-8.5.31.jar:8.5.31]

如您所见,它无法启动嵌入式 tomcat 组件。这是我的相关文件。


猛跑小猪
浏览 150回答 2
2回答

慕哥9229398

<tomcat.version>9.0.12</tomcat.version>从 pom.xml 中删除并尝试。

慕村225694

添加tomcat依赖以部署war..<dependency>&nbsp; <groupId>org.springframework.boot</groupId>&nbsp; <artifactId>spring-boot-starter-tomcat</artifactId>&nbsp; <scope>provided</scope></dependency><tomcat.version>9.0.12</tomcat.version>不需要删除。通过运行清理您的项目 mvn clean install如果仍然存在冲突的嵌入式 tomcat jar 问题,那么也从 web 中排除 tomcat。&nbsp;<dependency>&nbsp; &nbsp; &nbsp; &nbsp; <groupId>org.springframework.boot</groupId>&nbsp; &nbsp; &nbsp; &nbsp; <artifactId>spring-boot-starter-web</artifactId>&nbsp; &nbsp; &nbsp; &nbsp; <exclusions>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <exclusion>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <groupId>org.springframework.boot</groupId>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <artifactId>spring-boot-starter-tomcat</artifactId>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </exclusion>&nbsp; &nbsp; &nbsp; &nbsp; </exclusions>&nbsp; &nbsp; </dependency>
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java