简体   繁体   English

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

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

I am running a java spring boot application as jar file with DCEVM hot-swap agent.我正在使用 DCEVM 热插拔代理运行 java spring 启动应用程序作为 jar 文件。 When i change some class files in my jar file the application is not reloading those changes.当我更改 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. 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.

Running extracted jar file:运行提取的 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

after running above command if I am making any changes and recompiling and then replacing updated class file then the changes are detected and my app reflects the changes.运行上述命令后,如果我进行任何更改并重新编译然后替换更新的 class 文件,则检测到更改并且我的应用程序反映了更改。

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

I get above log which tells me that class is reloaded.我得到上面的日志,它告诉我 class 已重新加载。 everything works fine.一切正常。

Running jar file:运行 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

After running If I update the jar file with following command:运行后如果我使用以下命令更新 jar 文件:

jar uf app.jar path/HealthController.class

jar file gets updated but changes does not reflect and there is no log generated. jar 文件已更新,但更改未反映且未生成日志。

HotswapAgent does not detect class modification inside jar file. HotswapAgent 未检测到 jar 文件中的 class 修改。 Instead of it you can use extraClasspath config param.取而代之的是,您可以使用 extraClasspath 配置参数。 Look at http://hotswapagent.org/mydoc_configuration.html how to setup it.查看http://hotswapagent.org/mydoc_configuration.html如何设置它。

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

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