且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

嵌入式Tomcat 8.5的Tomcat Maven插件

更新时间:2022-10-31 18:39:31

是的,我认为在这里使用spring boot配置是***的选择. 要使用特定的tomcat版本,您应该执行以下步骤:

1-确保在pom.xml中具有spring boot作为项目<parent>:

 <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>

就是这样,导入新的依赖项,应用程序应以您在步骤2中指定的版本作为嵌入式Tomcat运行.

话虽如此,请注意某些tomcat版本存在一些问题.我建议您,如果要使用8.5.X版本,请使用我测试过的8.5.35,它可以正常工作.

希望这对您有所帮助.

I'm running a Spring web application and failing to execute embedded tomcat in latest Eclipse with Tomcat 8.5 using Tomcat 7 Maven Plugin , I'm running tomcat7:run-war goal on windows but failed to configure it to run Tomcat 8.5, it keeps finding tomcat 7 folder.

tomcat7:run-war Runs the current project as a packaged web application using an embedded Tomcat server.

I found answer or this answer but it's good for deploying tomcat .

I found in a deleted link tomcat8 plugin. Is it relevant?

I found issue that suggest use spring boot feature instead, can someone provide more details?

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

Especially when Spring Boot 2.1 won't support Tomcat7

Yeah, I think that using spring boot configuration is the best option here. To use a specific tomcat version you should do the following steps:

1- Make sure that you have spring boot as the project <parent> in your 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- Add the tomcat.version to <properties>:

<properties>
    ...
    <tomcat.version>8.5.35</tomcat.version>
    ...
</properties>

And that's it, import the new dependencies and the application should run as an embedded Tomcat with the version that you specify in step 2.

Having said that, be aware that there are some issues with certain tomcat versions. I would suggest you that, if you want to use an 8.5.X version, use the 8.5.35 which I tested and it's working perfectly.

Hope this helps you.