eclipse maven 多工程 多模块 jrebel jeety 热加载 无需 maven install

来源:互联网 发布:linux nat映射查看 编辑:程序博客网 时间:2024/05/15 01:19

父子工程结构

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'.

1 1
原创粉丝点击