tomcat7 启动调试, maven 自动部署到tomcat.
apache-tomcat-7.0.77
启动tomcat调试:
添加以下红色代码到catalina.bat, catalina.bat 会被startup.bat调用。
rem Execute Java with the applicable properties if not "%JPDA%" == "" goto doJpda if not "%SECURITY_POLICY_FILE%" == "" goto doSecurity %_EXECJAVA% %LOGGING_CONFIG% %LOGGING_MANAGER% %JAVA_OPTS% %CATALINA_OPTS% -Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=9527,suspend=n %DEBUG_OPTS% -Djava.endorsed.dirs="%JAVA_ENDORSED_DIRS%" -classpath "%CLASSPATH%" -Dcatalina.base="%CATALINA_BASE%" -Dcatalina.home="%CATALINA_HOME%" -Djava.io.tmpdir="%CATALINA_TMPDIR%" %MAINCLASS% %CMD_LINE_ARGS% %ACTION% goto end
tomcat 7 自动部署
1. 给tomcat 添加用户
<role rolename="admin-gui"/> <role rolename="admin-script"/> <role rolename="manager-gui"/> <role rolename="manager-script"/> <role rolename="manager-jmx"/> <role rolename="manager-status"/> <user username="admin" password="admin" roles="manager-gui,manager-script,manager-jmx,manager-status,admin-script,admin-gui"/>
2. 修改maven settting.xml.
<server> <id>tomcat</id> <username>admin</username> <password>admin</password> </server>
3. 设置tomcat maven插件.
Apache Maven 3.3.9
<plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <version>2.2</version> <configuration> <url>http://localhost:8080/manager/text</url> <!-- server、username、password对应maven的setting下的配置 --> <server>tomcat</server> <username>admin</username> <password>admin</password> <path>/${project.build.finalName}</path> <!-- war文件路径缺省情况下指向target --> <!--<warFile>${basedir}/target/${project.build.finalName}.war</warFile>--> </configuration> </plugin>
4. 执行命令:
mvn clean
mvn package
mvn tomcat7:redeploy.