Linux系統中,將web專案部署到tomcat中
阿新 • • 發佈:2018-12-16
RT
1. 將專案打成war包:執行maven命令 package命令生成的war包
注: eclipse 中使用 maven -install
2. 將 war 包放到Linux環境中 tomcat 目錄下的 wapps 下就好
3. 實現tomcat的熱部署: 即tomcat(Liunx)在啟動狀態下也可以實現專案部署,無需重啟
修改 tomcat 的 conf/tomcat-users.xml 配置檔案。新增使用者名稱、密碼、許可權。如下
<role rolename="manager-gui" /> <role rolename="manager-script" /> <user username="username" password="password" roles="manager-gui, manager-script"/>
注: 請求地址 http://localhost:8080/manager 輸入帳號密碼
使用maven的 tomcat 外掛實現熱部署:
pom中追加 tomcat 外掛配置
配置為自己的tomcat資訊
<plugins> <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <version>2.2</version> <configuration> <port>8080</port> <path>/</path> <url>http://localhost:8080/manager/text</url><!--url為tomcat訪問路徑--> <username>username</username> <!--之前設定的使用者名稱--> <password>password</password> <!--之前設定的密密碼--> </configuration> </plugin> </plugins>
Maben build…,第一次部署時Goals中輸入:clean tomcat7:deploy