Skip to content

Commit 9c1bd47

Browse files
committed
idea 集成 maven-tomcat pulgin
1 parent 4984314 commit 9c1bd47

File tree

5 files changed

+106
-1
lines changed

5 files changed

+106
-1
lines changed
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
---
2+
layout: post
3+
title: IDEA配置maven tomcat插件Debug/热部署
4+
categories: tools
5+
tags: idea
6+
---
7+
8+
* content
9+
{:toc}
10+
11+
# 配置maven tomcat插件
12+
13+
## 集成tomcatX-maven-plugin
14+
15+
```xml
16+
<plugin>
17+
<groupId>org.apache.tomcat.maven</groupId>
18+
<artifactId>tomcat7-maven-plugin</artifactId>
19+
<!-- or if you want to use tomcat 6.x -->
20+
<!--<artifactId>tomcat6-maven-plugin</artifactId>-->
21+
<version>2.2</version>
22+
<configuration>
23+
<path>/</path>
24+
</configuration>
25+
</plugin>
26+
```
27+
28+
现在只需要运行就可以运行项目了
29+
30+
```
31+
mvn clean tomcat7:run
32+
```
33+
> 但是这仅仅是运行项目,在这种情况下不能debug也没有热部署的功能,每次必须进行关闭 **mvn tomcat7:shutdown**
34+
35+
## Idea Debug配置
36+
37+
* 添加maven的Run/Debug项(Run->Edit Config)
38+
39+
![选择maven](./img/idea_debug.jpg)
40+
41+
* 填写相应的命令
42+
43+
![填写运行命令](./img/idea_debug_2.jpg)
44+
45+
> 这样只要进行debug启动就可以调试了但是,改完以后idea是不会自动部署的。
46+
47+
## Idea 热部署
48+
49+
> 这种方法是通过tomcat的管理后天进行热部署
50+
51+
### 相关的步骤如下
52+
53+
* 修改tomcat的tomcat-users.xml
54+
```xml
55+
<role rolename="admin"/>
56+
<role rolename="admin-gui"/>
57+
<role rolename="manager"/>
58+
<role rolename="manager-script"/>
59+
<role rolename="manager-gui"/>
60+
<role rolename="manager-jmx"/>
61+
<role rolename="manager-status"/>
62+
<user username="admin" password="admin" roles="admin,manager,manager-gui,admin-gui,manager-script,manager-jmx,manager-status"/>
63+
```
64+
* 修改的pom文件的配置
65+
66+
```xml
67+
<plugin>
68+
<groupId>org.apache.tomcat.maven</groupId>
69+
<artifactId>tomcat7-maven-plugin</artifactId>
70+
<!-- or if you want to use tomcat 6.x -->
71+
<!--<artifactId>tomcat6-maven-plugin</artifactId>-->
72+
<version>2.2</version>
73+
<configuration>
74+
<url>http://localhost:8080/manager/text</url>
75+
<server>tomcat</server>
76+
<username>admin</username>
77+
<password>admin</password>
78+
<uriEncoding>UTF-8</uriEncoding>
79+
<path>/</path>
80+
</configuration>
81+
</plugin>
82+
```
83+
* 修改maven的setting.xml文件
84+
85+
编辑**~/.m2/setting.xml** 添加如下内容:
86+
87+
```xml
88+
<settings>
89+
<servers>
90+
<server>
91+
<id>tomcat</id><!-- 这里的id和pom文件定义的server一致 -->
92+
<username>admin</username>
93+
<password>admin</password>
94+
</server>
95+
</servers>
96+
</settings>
97+
```
98+
> 现在可以通过命令行来启动tomcat(**注意:是在外部不是通过mvn tomcat7:run进行启动的,因为这种条件下启动的配置和通过tomcat命令启动是不同的**
99+
100+
现在通过**mvn tomcat7:deploy**进行部署就可以了
101+
102+
最后还是没有实现maven-tomcat插件既能debug又能热部署(又没闲钱使用JReble的服务,只能凑合着了),如果后续有好的方法在更新此文。

_posts/tools/2017-06-26-chrome_hot_key_usefull.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ tags: chrome
88
* content
99
{:toc}
1010

11-
#chrome 常用快捷键(linux)
11+
# chrome 常用快捷键(linux)
1212

1313
## 标签页和窗口
1414

_posts/tools/img/idea_debug.jpg

50.8 KB
Loading

_posts/tools/img/idea_debug_2.jpg

49 KB
Loading

page/3collections.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ type: page
4545
- [google fonts](https://fonts.google.com/)
4646
- [Google Fonts 加速代理](https://fengmk2.com/blog/2016/google-fonts-mirror)
4747

48+
* chrome 插件
49+
* AdBlock, Octotree, Postman, Postman Interceptor,switchyOmega, User_agent switcher, 有道云笔记, 有道翻译, devdocs
50+
4851
## 编程语言
4952

5053
### JavaScript

0 commit comments

Comments
 (0)