【问题标题】:Tomcat Maven Plugin for embedded Tomcat 8.5用于嵌入式 Tomcat 8.5 的 Tomcat Maven 插件
【发布时间】:2019-03-23 08:16:59
【问题描述】:

我正在运行 Spring Web 应用程序,但无法使用 Tomcat 7 Maven Plugin 在带有 Tomcat 8.5 的最新 Eclipse 中执行嵌入式 tomcat,我正在 Windows 上运行 tomcat7:run-war 目标,但未能将其配置为运行 Tomcat 8.5,它保持找到 tomcat 7 文件夹。

tomcat7:run-war 使用嵌入式 Tomcat 服务器将当前项目作为打包的 Web 应用程序运行。

我找到了answerthis answer,但这对部署 tomcat 很有用。

我在a deleted linktomcat8 插件中找到。有关系吗?

我发现issue 建议改用spring boot 功能,有人可以提供更多详细信息吗?

看来这个项目已经死了,我建议你考虑使用具有非常相似功能的 Spring Boot: https://spring.io/projects/spring-boot

尤其是Spring Boot 2.1 不支持 Tomcat7 时

【问题讨论】:

    标签: java spring maven spring-boot tomcat


    【解决方案1】:

    是的,我认为这里使用 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 添加到&lt;properties&gt;

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

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

    话虽如此,请注意某些 tomcat 版本存在一些问题。我建议您,如果您想使用 8.5.X 版本,请使用我测试过的 8.5.35,它可以完美运行。

    希望对你有所帮助。

    【讨论】:

    • 谢谢回答,有没有不用spring boot的方法? tomcat 8.5.23 也有问题吗?
    • 当我将 8.5.23 Tomcat 版本与 Spring Boot 2.1.1.RELEASE 版本结合使用时,它对我不起作用。我推荐 spring boot 解决方案,但如果您想以非 boot spring 方式执行此操作,我建议您将这个问题与接受的答案一起使用:stackoverflow.com/questions/45169586/… 如果它对您有帮助,请告诉我 :)跨度>
    • 我对您有帮助吗?如果是这样,赏金将不胜感激:)
    猜你喜欢
    • 2012-11-04
    • 2015-06-21
    • 2010-11-25
    • 2014-03-07
    • 2023-03-05
    • 2011-06-23
    • 2012-05-30
    • 1970-01-01
    • 2017-07-22
    相关资源
    最近更新 更多