配置Tomcat的Maven插件

13 篇文章 0 订阅
5 篇文章 0 订阅

如果你使用的是Idea编辑器社区版,你可选择配置Tomcat的Maven插件的方式来使用Tomcat。

<!-- Tomcat -->
<plugin>
    <groupId>org.apache.tomcat.maven</groupId>
    <artifactId>tomcat7-maven-plugin</artifactId>
    <version>2.2</version>
    <configuration>
        <path>/${project.artifactId}</path>
    </configuration>
</plugin>

配置tomcat的插件,更新maven后可以在插件里看到有tomcat,并且可以使用它的run命令:


你可以直接双击执行它,也可以右键debug执行,tomcat启动后log如下:

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building chapter1 1.0.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> tomcat7-maven-plugin:2.2:run (default-cli) @ chapter1 >>>
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ chapter1 ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.3:compile (default-compile) @ chapter1 ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to D:\IdeaProjects\Smart4jFramework\Chapter1\target\classes
[INFO]
[INFO] <<< tomcat7-maven-plugin:2.2:run (default-cli) @ chapter1 <<<
[INFO]
[INFO] --- tomcat7-maven-plugin:2.2:run (default-cli) @ chapter1 ---
[INFO] Running war on http://localhost:8080/chapter1
[INFO] Using existing Tomcat server configuration at D:\IdeaProjects\Smart4jFramework\Chapter1\target\tomcat
[INFO] create webapp with contextPath: /chapter1
十一月 01, 2016 10:43:24 上午 org.apache.coyote.AbstractProtocol init
信息: Initializing ProtocolHandler ["http-bio-8080"]
十一月 01, 2016 10:43:24 上午 org.apache.catalina.core.StandardService startInternal
信息: Starting service Tomcat
十一月 01, 2016 10:43:24 上午 org.apache.catalina.core.StandardEngine startInternal
信息: Starting Servlet Engine: Apache Tomcat/7.0.47
十一月 01, 2016 10:43:26 上午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["http-bio-8080"]


注意一下:

tomcat的maven插件版本好像只到tomcat7,虽然在maven官方可以看到有tomcat8的插件,但导入后并不显示第二张图上的插件,并且有错误提示。而且官方的例子也是到tomcat7为止。

关于tomcat的Maven官方插件库:https://mvnrepository.com/artifact/org.apache.tomcat.maven

Tomcat的官方例子:https://tomcat.apache.org/maven-plugin-trunk/


对于tomcat  maven plugin的一些设置项,请参看官方文档:

https://tomcat.apache.org/maven-plugin-trunk/run-mojo-features.html





  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值