繁体   English   中英

如何在 jar 文件更新中使用 DCEVM/热插拔代理?

[英]How to use DCEVM/Hotswap Agent with jar file update?

我正在使用 DCEVM 热插拔代理运行 java spring 启动应用程序作为 jar 文件。 当我更改 jar 文件中的一些 class 文件时,应用程序不会重新加载这些更改。 But If I extract my jar file and run my application as a simple java class file adding all dependencies to class path( like how IntelliJ Idea does) then replace any of the class file it reloads successfully.

运行提取的 jar 文件:

java -XXaltjvm=dcevm -javaagent:path/hot-swap/hotswap-agent-1.3.1-SNAPSHOT.jar=autoHotswap=true -Dspring.profiles.active=local -Dserver.port=8082 -classpath path/jdk1.8.0_191.jdk/Contents/Home/jre/lib/charsets.jar:--jdk-lib-jars:./path/classes:..other-jar-file-path com.company.app.App

运行上述命令后,如果我进行任何更改并重新编译然后替换更新的 class 文件,则检测到更改并且我的应用程序反映了更改。

HOTSWAP AGENT: 15:35:55.349 RELOAD (org.hotswap.agent.config.PluginManager) - Reloading classes [com.company.controller.HealthController] (autoHotswap)

我得到上面的日志,它告诉我 class 已重新加载。 一切正常。

运行 jar 文件:

java -XXaltjvm=dcevm -javaagent:path/hot-swap/hotswap-agent-1.3.1-SNAPSHOT.jar=autoHotswap=true -Dspring.profiles.active=local -Dserver.port=8081 -jar app.jar

运行后如果我使用以下命令更新 jar 文件:

jar uf app.jar path/HealthController.class

jar 文件已更新,但更改未反映且未生成日志。

HotswapAgent 未检测到 jar 文件中的 class 修改。 取而代之的是,您可以使用 extraClasspath 配置参数。 查看http://hotswapagent.org/mydoc_configuration.html如何设置它。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM