eclipse jetty-maven-plugin下通过jrebel实现动态加载

在eclipse中开发web工程,使用jetty-maven-plugin插件可以大大提高开发和测试效率,但是jetty-maven-plugin对于热部署(动态加载class)的支持并不是太好,所以现在通过引入jrebel来实现动态加载功能。

jrebel

下载jrebel,解压到本地目录,备用。

http://pan.baidu.com/s/1kUNFdiB 解压密码:j2ee.cc

说明:该jrebel版本来源于网络,仅限用于相关测试,请下载24小时后删除

pom.xml配置

pom.xml文件加载jetty-maven-plugin(运行jetty服务)插件和maven-compiler-plugin(编译)插件:

<plugin>
	<groupId>org.mortbay.jetty</groupId>
	<artifactId>jetty-maven-plugin</artifactId>
	<version>8.1.16.v20140903</version>
	<configuration>
		<scanIntervalSeconds>0</scanIntervalSeconds>
		<webApp>
			<contextPath>/myweb</contextPath>
		</webApp>
	</configuration>
</plugin>

<plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-compiler-plugin</artifactId>
	<version>2.3.2</version>
	<configuration>
		<source>1.8</source>
		<target>1.8</target>
		<encoding>UTF-8</encoding>
	</configuration>
</plugin>

其中,建议将scanIntervalSeconds的值设置为0

eclipse运行配置

配置jvm运行参数

-noverify
-javaagent:e:/jrebel_6.4.8_agent_crack/jrebel.jar
-Drebel.spring_plugin=true
-Drebel.disable_update=true

其中<code>e:/jrebel_6.4.8_agent_crack/jrebel.jar</code>是本地jrebel的位置

最后在eclipse中通过maven命令启动jetty服务,命令如下:

jetty:run -Djetty.port=8080

jetty取消映射缓存

jetty 默认开启了 useFileMappedBuffer,在 jetty 运行期间,页面所使用的静态文件(如 css 文件等)不允许修改。如果你尝试去修改它们,保存的时候就会出现 Save could not be completed.

解决办法,找到 %repo%/org/eclipse/jetty/jetty-webapp/8.1.16.v20140903/jetty-webapp-8.1.16.v20140903.jar(%repo% 表示你 本地的 maven 仓库的目录,另外,将 8.1.16.v20140903换成你所使用的版本)。用压缩工具打开它, 找到 jetty-webapp-8.1.16.v20140903.jar/org/eclipse/jetty/webapp/webdefault.xml,修改 webdefault.xml 文件,用文本编辑器打开它,搜索找到 useFileMappedBuffer 配置的行,将 true 改成 false 以禁掉缓存。

<init-param>
  <param-name>useFileMappedBuffer</param-name>
  <param-value>false</param-value>
</init-param>

将修改好的 webdefault.xml 文件重新压缩进去即可。

转载于:https://my.oschina.net/dwp/blog/861814

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值