關於maven-jetty-plugin 自動重啓問題

 1             <plugin>
 2                 <groupId>org.mortbay.jetty</groupId>
 3                 <artifactId>maven-jetty-plugin</artifactId>
 4                 <version>6.1.26</version>
 5                 <configuration>
 6                     <!-- 每2秒的間隔掃描一次,實現熱部署 -->
 7                     <scanIntervalSeconds>2</scanIntervalSeconds>
 8                     <contextPath>/</contextPath>
 9                 </configuration>
10             </plugin>

代碼如上面所示:每次保存代碼時 jetty插件會按 <reload>automatic</reload>默認設置自動reload,jetty從新啓動web

要實現手動控制jetty的從新啓動設置以下:maven

 1             <plugin>
 2                 <groupId>org.mortbay.jetty</groupId>
 3                 <artifactId>maven-jetty-plugin</artifactId>
 4                 <version>6.1.26</version>
 5                 <configuration>
 6                     <!-- 每2秒的間隔掃描一次,實現熱部署 -->
 7                     <scanIntervalSeconds>2</scanIntervalSeconds>
 8                     <reload>manual</reload>
 9                     <contextPath>/</contextPath>
10                 </configuration>
11             </plugin>

 

注意:有的jetty插件版本不支持<reload></reload>,注意版本的選擇。spa

手動重載插件

Jetty 6.2.0pre0版本起,添加了一個新的可用組件,用於控制web應用的從新部署。命令行

配置參數:<reload>[manual|automatic]</reload>code

當你設置成手動模式後,web應用不會自動的掃描和重部署。相反,用戶能夠控制的Web應用時,經過鍵入回車換行鍵重載。當設置成自動模式時,將根據scanIntervalSeconds參數的設置不定時的掃描和自動重部署。你也能經過在命令行使用系統參數
-Djetty.reload 配置選擇重載的模式。
xml

好比:"mvn -Djetty.reload=manual jetty:run" 將強制手動重載,無論pom.xml文件裏如何配置。同理: "mvn -Djetty.reload=automatic -Djetty.scanIntervalSeconds=10 jetty:run" 每隔十秒中後臺將重載一次,而無論pom.xml文件裏如何配置。blog

相關文章
相關標籤/搜索