簡體   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