• Maven Jrebel 多模块热部署方案


    近期在构建maven多模块项目时,发现web module依赖的其它模块,每次都要clean install成一个jar包,然后运行web module才能加载。

    本生jrebel是配置在了web module主模块上,只要修改的是web模块里面的java文件都会自动reloading加载。

    这个问题正在寻找解决办法。时刻会更新到这里,如果有谁有解决办法可以帮帮忙。

    更新,经过多重测试,在web模块pom中增加红色字体部分,就ok了。启动的时候,会直接编译依赖模块的target/classes,就直接忽略了clean install产生的jar,

    再有就是在修改依赖module项目java类的时候,jrebel会自动reloading class

    2015-03-25 00:48:46 JRebel: Reloading class 'com.xx.api.data.user.service.UserProfileService'.

    提示上面一句话就证明ok拉。下面是我web模块的部分配置。请参考,也可以联系我的微信:benyzhous

    		<plugins>
    			<plugin>
    				<groupId>org.apache.maven.plugins</groupId>
    				<artifactId>maven-compiler-plugin</artifactId>
    				<version>2.3.2</version>
    				<configuration>
    					<source>1.7</source>
    					<target>1.7</target>
    				</configuration>
    			</plugin>
    			<!-- 配置 maven 的 jetty 插件 -->
    			<plugin>
    				<groupId>org.mortbay.jetty</groupId>
    				<artifactId>jetty-maven-plugin</artifactId>
    				<version>7.2.2.v20101205</version>
    				<configuration>
    					<webAppConfig>
    						<contextPath> /${project.artifactId}</contextPath>
    						<!-- 指定 root context 在这里指定为${project.artifactId} 即 jetty, 那么访问时就用http://localized:8080/jetty 访问, 如果指定梶为test 就用http://localized:8080/test访问,更多信息,请查看jetty 
    							插件官方文档 -->
    						<span style="color:#ff0000;"><!-- 设置其他项目extraClasspath,多个用";"隔开 -->
    						<extraClasspath>
    						../data-service/target/classes;
    						</extraClasspath> </span>
    					</webAppConfig>
    
    					<scanTargets>
    						<!-- <scanTarget>../data-service/target/classes</scanTarget> -->
    					</scanTargets>
    
    					<!-- 指定额外需要监控变化的文件或文件夹,主要用于热部署中的识别文件更新 -->
    					<scanTargetPatterns>
    						<scanTargetPattern>
    							<directory>src</directory>
    							<includes>
    								<include>**/*.java</include>
    								<include>**/*.properties</include>
    							</includes>
    							<!-- <excludes> <exclude>**/*.xml</exclude> <exclude>**/myspecial.properties</exclude> </excludes> -->
    						</scanTargetPattern>
    					</scanTargetPatterns>
    					<scanIntervalSeconds>0</scanIntervalSeconds><!-- 指定监控的扫描时间间隔,0为关闭jetty自身的热部署,主要是为了使用jrebel -->
    					<webAppSourceDirectory>${basedir}/src/main/webapp</webAppSourceDirectory><!-- 指定web页面的文件夹 -->
    				</configuration>
    			</plugin>
    
    			<!-- jerebel maven 插件,用于生成jrebel.xml -->
    			<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>
    		<outputDirectory>${basedir}/src/main/webapp/WEB-INF/classes</outputDirectory>
    		<!-- 指定编译后文件的存放路径,因为jetty默认src/main/webapp为 web应用的根目录而 maven compile 目标后的默认classpath 在target文件夹下,就造成jrebel.xml无法兼顾 jetty 
    			默认的是webapp中的classes为 web 应用的根目录, 而maven 默认是target 目录所以需要修改该maven的默认classes目录。 -->


  • 相关阅读:
    hibernate-取消关联外键引用数据丢失抛异常的设置@NotFound
    css-画三角箭头
    tomcat提示警告: An attempt was made to authenticate the locked user"tomcat"
    liunx下tomcat启动 Cannot find ./catalina.sh
    java:提示Could not initialize class sun.awt.X11GraphicsEnvironment
    MySQL定时器开启、调用实现代码
    mysql-存储过程案例-存储过程中创建表和修改表数据
    PowerDesigner导出SQL时自动生成注释
    mysql-利润set变量模拟分组查询每组中的第N条数据
    HTTP 405 错误 – 方法不被允许 (Method not allowed)
  • 原文地址:https://www.cnblogs.com/duyinqiang/p/5696755.html
Copyright © 2020-2023  润新知