我正在运行一个 Spring Web 应用程序,但无法使用 Tomcat 7 Maven Plugin 在带有 Tomcat 8.5 的最新 Eclipse 中执行嵌入式 tomcat ,我在 Windows 上运行 tomcat7:run-war
目标,但未能将其配置为运行 Tomcat 8.5,它一直在寻找 tomcat 7 文件夹。
tomcat7:run-war Runs the current project as a packaged web application using an embedded Tomcat server.
我找到了 answer或 this answer但它有利于部署 tomcat。
我在 a deleted link 中找到tomcat8插件。是否相关?
我找到了 issue建议改用 spring boot 功能,有人可以提供更多详细信息吗?
it appears this project is dead, I recommend you look into using Spring Boot which has very similar features: https://spring.io/projects/spring-boot
特别是当Spring Boot 2.1不支持Tomcat7
最佳答案
是的,我认为在这里使用 spring boot 配置是最好的选择。 要使用特定的 tomcat 版本,您应该执行以下步骤:
1- 确保你有 spring boot 作为项目 <parent>
在你的 pom.xml 中:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.1.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
2- 添加 tomcat.version
至 <properties>
:
<properties>
...
<tomcat.version>8.5.35</tomcat.version>
...
</properties>
就是这样,导入新的依赖项,应用程序应该作为嵌入式 Tomcat 运行,并具有您在步骤 2 中指定的版本。
话虽如此,请注意某些 tomcat 版本存在一些问题。我建议您,如果您想使用 8.5.X 版本,请使用我测试过的 8.5.35,它运行良好。
希望对你有帮助。
关于java - 用于嵌入式 Tomcat 8.5 的 Tomcat Maven 插件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52875414/