| --- | --- | | 1
2
3
4
5
6
7
8
9
10
11
12
13
14 |
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat6-maven-plugin</artifactId>
<version>
2.3
-SNAPSHOT</version>
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>
2.3
-SNAPSHOT</version>
</plugin>
</plugins>
</pluginManagement>
|
或者添加 groupId 到你的 settings.xm
| 1 |
2
3
4
5 |
<pluginGroups>
....
<pluginGroup>org.apache.tomcat.maven</pluginGroup>
....
</pluginGroups>
|
在 tomcat 发布不显示项目名称
配置如下
| 1 |
2
3
4
5
6
7
8 |
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>
2.2
</version>
<configuration>
<path>/</path>
</configuration>
</plugin>
|
Context Goals
部署 WAR 项目
在 tomcat:deploy 部署后,再次部署 WAR 执行:
| 1 | |
mvn
package
tomcat6/
7
:redeploy
|
在执行 tomcat:exploded 后,再次部署 WAR 执行:
| 1 | |
mvn war:exploded tomcat6/
7
:redeploy
|
在执行 tomcat:inplace 后,再次部署 WAR 执行:
| 1 | |
mvn war:inplace tomcat6/
7
:redeploy
|
在执行 tomcat:deploy 后,再次部署 context.xml 文件执行:
| 1 | |
mvn tomcat6/
7
:redeploy
|
注意: context.xml指定 docBase后 ,还需要像上面那样调用 war:exploded或者war:inplace
移除部署 WAR 项目
| 1 | |
mvn tomcat6/
7
:undeploy
|
启动 WAR 项目
| 1 | |
mvn tomcat6:start
|
停止 WAR 项目
| 1 | |
mvn tomcat6:stop
|
列出会话统计表
| 1 | |
mvn tomcat6:sessions
|
Container Goals
列出部署的应用s
| 1 | |
mvn tomcat6:list
|
列出服务器信息
| 1 | |
mvn tomcat6:info
|
列出 JNDI 资源
列出 Tomcat 版本, 操作系统, 和 JVM 等信息
| 1 | |
mvn tomcat6:resources
|
另外,列出特定类型你可以只输入 JNDI 资源类型:
| 1 | |
mvn -Dmaven.tomcat.type=my.
class
.name tomcat6:resources
|
列出安全角色
| 1 | |
mvn tomcat6:roles
|
构建一个可执行的 War/Jar
版本 2.0 开始,嵌入的 Apache Tomcat7 可以构建一个可执行的 War/Jar(只支持 tomcat7 插件)
注意:项目必须有 pom 或者 war 的打包信息
添加到您的 war 模块:
| 1 |
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36 |
<project>
...
<packaging>war or pom</packaging>
...
<build>
...
<plugins>
...
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>
2.3
-SNAPSHOT</version>
<executions>
<execution>
<id>tomcat-run</id>
<goals>
<goal>exec-war-only</goal>
</goals>
<phase>
package
</phase>
<configuration>
<path>foo</path>
<!-- optional, needed only
if
you want to use a preconfigured server.xml file -->
<serverXml>src/main/tomcatconf/server.xml</serverXml>
<!-- optional values which can be configurable -->
<attachArtifactClassifier>
default
value is exec-war but you can customize</attachArtifactClassifier>
<attachArtifactClassifierType>
default
value is jar</attachArtifactClassifierType>
</configuration>
</execution>
</executions>
</plugin>
...
</plugins>
...
</build>
...
</project>
|
添加到 pom 模块
| 1 |
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60 |
<project>
...
<packaging>war</packaging>
...
<build>
...
<plugins>
...
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>
2.3
-SNAPSHOT</version>
网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。
一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!