当一个项目使用maven多模块开发时通过上面的配置, 只能自动加载webapp所在的模块, 若想改动其他模块的代码也要自动加载, 需在项目的根(父)pom.xml文件中加入下面的配置:
<build> <-- 只需要复制两个 plugin 标签及里面的内容即可,build 和 plugins 标签是为了更容易理解两个 plugin 标签的放置位置 -->
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.zeroturnaround</groupId>
<artifactId>jrebel-maven-plugin</artifactId>
<version>1.1.5</version>
<configuration>
<addResourcesDirToRebelXml>true</addResourcesDirToRebelXml>
<alwaysGenerate>true</alwaysGenerate>
<showGenerated>true</showGenerated>
</configuration>
<executions>
<execution>
<id>generate-rebel-xml</id>
<phase>process-resources</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
将两个 plugin 标签的内容复制到pom.xml文件后,右键点击pom.xml文件,选择maven->ReImport(首先要确保该项目是maven项目),maven会自动下载所需的文件(或者使用maven命令:mvn JRebel:generate)。