IDEA Smart Tomcat 配置 tomcat 启动 web 项目

开发中的项目发现漏洞,需要升级 *.jar 版本及 Tomcat 版本。

项目初始初始选型与 SpringBoot 无缘,同时最初使用的是tomcat7-maven-plugin来启动,公司要求开发软件正版化……

基于以上种种要求,软件版本升级面临的问题让人愈感压力巨大。虽然形势严峻,问题突出,压力巨大,但是工作还是要做的。

  1. *.jar 文件升级很快,修改pom.xml文件版本号,重新加载 Maven 修改即可。
  2. apache 官网下载 tomcat 8.5.* 最新版本并替换。

配置完成,重新启动项目,开发环境运行正常,测试验证一次通过,生产上线。这一切只存在于幻想中。


方法一:tomcat7-maven-plugin替换为tomcat8-maven-plugin就出现错误

No plugin found for prefix  'tomcat8' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (......), central (https://repo.maven.apache.org/maven2)] -> [Help 1]
[ERROR] 

参考多篇搜索结果配置大概如下,都无法达到目的,果断放弃。

    <build>
        <finalName>${project.artifactId}</finalName>
        <plugins>
            <!-- 资源文件拷贝插件 -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>3.2.0</version>
                <configuration>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
            <!-- java编译插件 -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.10.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
        </plugins>
 
        <pluginManagement>
            <plugins>
                <!-- 配置Tomcat插件 -->
                <plugin>
                    <groupId>org.apache.tomcat.maven</groupId>
                    <artifactId>tomcat8-maven-plugin</artifactId>
                    <version>3.0-r1756463</version>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

方法二:其他替代插件(未验证)

             <plugin>
                <groupId>org.codehaus.cargo</groupId>
                <artifactId>cargo-maven3-plugin</artifactId>
                <version>1.9.12</version>
                <configuration>
                    <container>
                        <containerId>tomcat8x</containerId>
                        <home>${env.CATALINA_HOME}</home>
                    </container>
                    <configuration>
                        <type>existing</type>
                        <home>${env.CATALINA_HOME}</home>
                    </configuration>
                    <deployables>
                        <deployable>
                            <groupId>com.yourcompany</groupId>
                            <artifactId>ROOT</artifactId>
                            <type>war</type>
                            <properties>
                                <context>${project.build.finalName}</context>
                            </properties>
                        </deployable>
                    </deployables>
                    <deployer>
                        <type>installed</type>
                    </deployer>
                </configuration>
            </plugin>

方法三:针对社区版 IDEA,配置tomcat需要用到Smart Tomcat

File -> Settings... -> Plugins -> Smart Tomcat

File -> Settings... -> Tomcat Server配置Tomcat 路径。

Edit Configurations...页面配置项目路径、端口号及参数。

  • Deployment Directory一定要设置到webapp
  • Context Path设置为/projectName即可
  • VM options可以设置VM参数,比如:-Dspring.profiles.active=test,同时也需要把未加载的*.properties文件参数-Dkey=value也写入。否则出现参数无法找到的错误。
    Caused by: java.lang.NumberFormatException: For input string: "${key}"
    
  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值