maven eclipse远程部署tomcat

pom.xml tomcat 配置信息
 <properties><project.build.sourceEncoding>utf8</project.build.sourceEncoding>//编码格式
  <finalName>shiro</finalName>//项目名称
 </properties>
 1 <!-- 插件 -->
 2     <url>http://mvnrepository.com/</url>  
 3     <repositories>  
 4         <repository>  
 5             <id>people.apache.snapshots</id>  
 6             <url>http://mvnrepository.com/</url>  
 7             <releases>  
 8                 <enabled>false</enabled>  
 9             </releases>  
10             <snapshots>  
11                 <enabled>true</enabled>  
12             </snapshots>  
13         </repository>  
14     </repositories>  
15       
16     <pluginRepositories>  
17         <pluginRepository>  
18             <id>apache.snapshots</id>  
19             <name>Apache Snapshots</name>  
20             <url>http://mvnrepository.com/</url>  
21             <releases>  
22                 <enabled>false</enabled>  
23             </releases>  
24             <snapshots>  
25                 <enabled>true</enabled>  
26             </snapshots>  
27         </pluginRepository>  
28     </pluginRepositories>
29     <build>
30         <finalName>${finalName}</finalName>//打包项目名称
31
<plugins> 32 <plugin> 33 <groupId>org.apache.tomcat.maven</groupId> 34 <artifactId>tomcat7-maven-plugin</artifactId> 35 <version>2.1</version> 36 <configuration> 37 <url>http://192.168.1.3:8080/manager/text</url> //tomcat管理页面路径,tomcat7 38 <path>/${finalName}</path> //项目访问路径 39 <server>com.self.deploy</server> 40 <username>admin</username> 41 <password>admin</password> 42 </configuration> 43 </plugin> 44 <plugin> 45 <groupId>org.apache.maven.plugins</groupId> 46 <artifactId>maven-compiler-plugin</artifactId> 47 <version>3.1</version> 48 <configuration> 49 <source>1.7</source> 50 <target>1.7</target> 51 </configuration> 52 </plugin> 53 54 </plugins> 55 <!-- mybatis的映射配置文件.xml --> 56 <resources> 57 <resource> 58 <directory>src/main/resources</directory> 59 <includes> 60 <include>**/*.properties</include> 61 <include>**/*.xml</include> 62 </includes> 63 <filtering>true</filtering> 64 </resource> 65 <resource> 66 <directory>src/main/java</directory> 67 <includes> 68 <include>**/*.xml</include> 69 </includes> 70 <filtering>true</filtering> 71 </resource> 72 </resources> 73 </build>


conf/tomcat-users.xml 用户权限配置,与webapp/manager/WEB-INF/web.xml中的role对应,下文异常2

1 <tomcat-users>
2 <role rolename="manager-gui"/> 
3 <role rolename="manager-script"/> 
4 <role rolename="manager-jmx"/> 
5 <role rolename="manager-status"/>  
6 <role rolename="admin-gui"/>  
7 <role rolename="admin-script"/>  
8 <user username="admin" password="admin" roles="manager-gui,manager-script,manager-jmx,manager-status,admin-gui,admin-script"/> 
9 </tomcat-users>

 

maven   conf\settings.xml

 1 <server><id>com.self.deploy</id><username>admin</username><password>admin</password></server> 

注:id与pom.xml<server>,账户密码一致

tomcat7:deploy  部署

tomcat7:redeploy 重新部署

异常1:[ERROR] Failed to execute goal org.apache.tomcat.maven:tomcat7-maven-plugin:2.1:redeploy (default-cli) on project shiro: Cannot invoke Tomcat manager: Connection to http://192.168.1.3:8080 refused: Connection refused: connect -> [Help 1]

原因:部署前未启动远程tomcat,部署前需要先启动远程tomcat

异常2:权限不足

 1 [INFO] tomcatManager status code:401, ReasonPhrase:Unauthorized
 2 [INFO] <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
 3 [INFO] <html>
 4 [INFO]  <head>
 5 [INFO]   <title>401 Unauthorized</title>
 6 [INFO]   <style type="text/css">
 7 [INFO]     <!--
 8 [INFO]     BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;font-size:12px;}
 9 [INFO]     H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;}
10 [INFO]     PRE, TT {border: 1px dotted #525D76}
11 [INFO]     A {color : black;}A.name {color : black;}
12 [INFO]     -->
13 [INFO]   </style>
14 [INFO]  </head>
15 [INFO]  <body>
16 [INFO]    <h1>401 Unauthorized</h1>
17 [INFO]    <p>
18 [INFO]     You are not authorized to view this page. If you have not changed
19 [INFO]     any configuration files, please examine the file
20 [INFO]     <tt>conf/tomcat-users.xml</tt> in your installation. That
21 [INFO]     file must contain the credentials to let you use this webapp.
22 [INFO]    </p>
23 [INFO]    <p>
24 [INFO]     For example, to add the <tt>manager-gui</tt> role to a user named
25 [INFO]     <tt>tomcat</tt> with a password of <tt>s3cret</tt>, add the following to the
26 [INFO]     config file listed above.
27 [INFO]    </p>
28 [INFO] <pre>
29 [INFO] &lt;role rolename="manager-gui"/&gt;
30 [INFO] &lt;user username="tomcat" password="s3cret" roles="manager-gui"/&gt;
31 [INFO] </pre>
32 [INFO]    <p>
33 [INFO]     Note that for Tomcat 7 onwards, the roles required to use the manager
34 [INFO]     application were changed from the single <tt>manager</tt> role to the
35 [INFO]     following four roles. You will need to assign the role(s) required for
36 [INFO]     the functionality you wish to access.
37 [INFO]    </p>
38 [INFO]     <ul>
39 [INFO]       <li><tt>manager-gui</tt> - allows access to the HTML GUI and the status
40 [INFO]           pages</li>
41 [INFO]       <li><tt>manager-script</tt> - allows access to the text interface and the
42 [INFO]           status pages</li>
43 [INFO]       <li><tt>manager-jmx</tt> - allows access to the JMX proxy and the status
44 [INFO]           pages</li>
45 [INFO]       <li><tt>manager-status</tt> - allows access to the status pages only</li>
46 [INFO]     </ul>
47 [INFO]    <p>
48 [INFO]     The HTML interface is protected against CSRF but the text and JMX interfaces
49 [INFO]     are not. To maintain the CSRF protection:
50 [INFO]    </p>
51 [INFO]    <ul>
52 [INFO]     <li>Users with the <tt>manager-gui</tt> role should not be granted either
53 [INFO]         the <tt>manager-script</tt> or <tt>manager-jmx</tt> roles.</li>
54 [INFO]     <li>If the text or jmx interfaces are accessed through a browser (e.g. for
55 [INFO]         testing since these interfaces are intended for tools not humans) then
56 [INFO]         the browser must be closed afterwards to terminate the session.</li>
57 [INFO]    </ul>
58 [INFO]    <p>
59 [INFO]     For more information - please see the
60 [INFO]     <a href="/docs/manager-howto.html">Manager App HOW-TO</a>.
61 [INFO]    </p>
62 [INFO]  </body>
63 [INFO] </html>
64 [INFO] ------------------------------------------------------------------------
65 [INFO] BUILD SUCCESS

 

posted @ 2016-06-12 17:09  flay  阅读(511)  评论(0编辑  收藏  举报