Maven專案釋出WEB專案部署到Tomcat
阿新 • • 發佈:2018-12-18
-
配置tomcat和maven
進入tomcat安裝目錄conf\tomcat_users.xml:修改如下:
<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="admin123" roles="manager-gui,manager-script,manager-jmx,manager-status,admin-script,admin-gui"/>
進入maven安裝目錄conf/settings.xml:修改如下:
<server> <id>tomcat7</id> <username>admin</username> <password>admin123</password> </server> </servers> 搜尋到mirrors,在mirrors節點下配置一下資訊,解決找不到資源問題 <mirrors> <mirror> <id>nexus-aliyun</id> <mirrorOf>*</mirrorOf> <name>Nexus aliyun</name> <url>http://maven.aliyun.com/nexus/content/groups/public</url> </mirror> </mirrors>
2.修改pom.xml
<plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <version>2.2</version> <configuration> <warFile>target/activity_system.war</warFile> <!-- 生成的專案war包> <server>tomcat7</server> <url>http://localhost:8088/activity_system</url> <path>/activity_system</path> </configuration> </plugin> 配置完成後進行執行後報錯,沒有進行編,網上找到如下解決方法,已驗證: <defaultGoal>compile</defaultGoal>
3.執行maven專案
右擊專案 maven -build
成功後會在專案中找到war包