eclipse maven 多工程 多模組 jrebel jeety 熱載入 無需 maven install
阿新 • • 發佈:2019-01-28
父子工程結構
parent
dao
service
webapp
1、eclipse 下載jrebel外掛,安裝並破解;或另一種方法是已下載jrebel包,在Arguments ---> VM arguments 中新增jrebel的使用路徑,這種比較原始,這個網上非常多,自己找吧。
2、webapp pom 加入
<build><finalName>webapp</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.2.17.v20160517</version> 這裡不同版本對應不同的jdk版本,而且不同版本下邊的配置項也不一樣,具體網上搜吧
<configuration>
<!-- 關閉jetty自身的熱部署 -->
<scanIntervalSeconds>0</scanIntervalSeconds>
<webApp>
<contextPath>/</contextPath>
<extraClasspath>
../service/target/classes;
../dao/target/classes;
</extraClasspath>
</webApp>
<!-- 指定額外需要監控變化的檔案或資料夾,主要用於熱部署中的識別檔案更新 -->
<scanTargetPatterns>
<scanTargetPattern>
<directory>src</directory>
<includes>
<include>**/*.java</include>
<include>**/*.properties</include>
</includes>
<!-- <excludes> <exclude>**/*.xml</exclude> <exclude>**/myspecial.properties</exclude> </excludes> -->
</scanTargetPattern>
</scanTargetPatterns>
<webAppSourceDirectory>${basedir}/src/main/webapp</webAppSourceDirectory><!-- 指定web頁面的資料夾 -->
<httpConnector>
<port>80</port>
</httpConnector>
</configuration>
</plugin>
<plugin>
<groupId>org.zeroturnaround</groupId>
<artifactId>jrebel-maven-plugin</artifactId>
<version>1.1.5</version>
<executions>
<execution>
<id>generate-rebel-xml</id>
<phase>process-resources</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<rebelXmlDirectory>${basedir}/src/main/webapp/WEB-INF/classes</rebelXmlDirectory>
<!-- 指定生成的jrebel.xml放在哪裡, 要求放在web應用的 classpath下 -->
</configuration>
</plugin>
</plugins>
<!-- 指定編譯後文件的存放路徑,因為jetty預設src/main/webapp為 web應用的根目錄
而 maven compile 目標後的預設classpath 在target資料夾下,就造成jrebel.xml無法兼顧 jetty
預設的是webapp中的classes為 web 應用的根目錄,
而maven 預設是target 目錄所以需要修改該maven的預設classes目錄。 -->
<outputDirectory>${basedir}/src/main/webapp/WEB-INF/classes</outputDirectory>
</build>
修改service工程中的程式碼:
2017-01-20 00:48:46 JRebel: Reloading class 'com.xx.api.data.user.service.UserProfileService'.