Java “热代码替换”不起作用——Eclipse 不会更改 JBoss 上的任何代码
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2673554/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
'Hot code replace' not working -- Eclipse doesn't change any code on JBoss
提问by
I'm currently experiencing a problem with 'hot code replace' not working on Eclipse Galileo and JBoss 4.2.3.
我目前在 Eclipse Galileo 和 JBoss 4.2.3 上遇到“热代码替换”问题。
Among other applications I'm running an exploded Java WAR on my local JBoss. The project from which it is build is managed by Maven. I build the project using the Maven goal war:exploded and then I copy that directory to JBoss with an ANT script.
在其他应用程序中,我在本地 JBoss 上运行了爆炸式 Java WAR。构建它的项目由 Maven 管理。我使用 Maven 目标 war:exploded 构建项目,然后使用 ANT 脚本将该目录复制到 JBoss。
When I'm now running the application and set a breakpoint anywhere in the code, Eclipse properly halts at that line in the debug mode. But when I'm making a change to the source file and save it, Eclipse doesn't apply this change to the JBoss. For example, when I make a normal code line into a comment, the debugger still steps over this comment as if it was regular Java code. Or when I remove a line, the debugger seems to get out of sync with the file and starts stepping over parenthesis.
当我现在运行应用程序并在代码中的任何位置设置断点时,Eclipse 会在调试模式下正确地停在该行。但是当我对源文件进行更改并保存时,Eclipse 不会将此更改应用于 JBoss。例如,当我将普通代码行放入注释时,调试器仍会跳过该注释,就好像它是普通 Java 代码一样。或者当我删除一行时,调试器似乎与文件不同步并开始跳过括号。
But I'm not getting any 'hot code replace error'-messages either. It seems to me that Eclipse applies the changes to the source files, but doesn't apply it to the JBoss.
但我也没有收到任何“热代码替换错误”消息。在我看来,Eclipse 将更改应用于源文件,但并未将其应用于 JBoss。
Are there any special preferences that have to be turned on in order to make hot code replace work? Or are there any mistakes in how I build and deploy the application to the JBoss?
是否必须打开任何特殊首选项才能使热代码替换工作?或者我在构建应用程序并将其部署到 JBoss 的过程中是否有任何错误?
采纳答案by Markus Lausberg
I did not work with JBoss but I have two suggestions.
我没有与 JBoss 合作过,但我有两个建议。
If you run your application in eclipse using the launch configuration
Is your "Project" - "Build Automatically" flag enabled? If not, the code is not compiled and ignored t runtime.When you debug an application in remote mode, you can not change the code, but you can change the value of parameters. (I think)
如果您使用启动配置在 Eclipse 中运行您的应用程序
您的“项目”-“自动构建”标志是否启用?如果不是,则不会编译代码并忽略运行时。在远程模式下调试应用程序时,您不能更改代码,但可以更改参数的值。(我认为)
回答by user513365
I had issues in a project with Maven and Eclipse. No errors were shown, but hot code replacement was not working. I read that "Build Automatically" has to be checked. I checked this and it still didnt work. I had some errors in other projects in my build path. I believe that was the error. When i researched, I found that the we had to uncheck the "Abort build when buildpath errors". I have given the details in the link below.
我在使用 Maven 和 Eclipse 的项目中遇到了问题。没有显示错误,但热代码替换不起作用。我读到必须检查“自动构建”。我检查了这个,它仍然没有工作。我在构建路径中的其他项目中遇到了一些错误。我相信那是错误。当我研究时,我发现我们必须取消选中“构建路径错误时中止构建”。我在下面的链接中提供了详细信息。
回答by Jose Manuel Gomez Alvarez
First check is the Project/Build automatically.
首先检查是自动项目/构建。
It may be also required to check the application server deploymentconfiguration,
可能还需要检查应用服务器部署配置,
E.g. for JBoss, in Eclipse, in the Servers view, double click on the server and there is a Deployment Scanners section with two check boxes:
例如,对于 JBoss,在 Eclipse 中,在服务器视图中,双击服务器,然后有一个带有两个复选框的部署扫描器部分:
- Add missing deployment scanners
- Remove added deployment scanners before shutdown
- 添加缺少的部署扫描程序
- 在关闭之前删除添加的部署扫描程序
https://docs.jboss.org/author/display/AS7/Deployment+Scanner+configurationJBoss AS/ Deployment Scanner configuration
https://docs.jboss.org/author/display/AS7/Deployment+Scanner+configuration JBoss AS/Deployment Scanner 配置
回答by callmejoc
I just recently had this problem in Eclipse 2019-06 and found I had to uncheck the option in "Replace classfiles containing compilation errors" in Preferences->Java->Debug->Hot Code Replace group. All the other options there were checked. Previous to doing that I was getting "Hot code replace failed - Delete method not implemented"despite my only change being to ass a System.out.println call. As soon as I changed that option ( in the same debug session ) it started working for me.
我最近在 Eclipse 2019-06 中遇到了这个问题,发现我必须取消选中Preferences->Java->Debug->Hot Code Replace 组中“替换包含编译错误的类文件”中的选项。检查了所有其他选项。在这样做之前,我得到了“热代码替换失败 - 未实现删除方法”,尽管我唯一的改变是调用 System.out.println 。一旦我更改了该选项(在同一个调试会话中),它就开始为我工作。