Spring 加载的类的 JVM 热交换,使用 JPDA
有人可以分享他关于这个话题的经验吗?
在 tomcat 上使用 jpda 时,类重新加载是否适用于通过 spring 加载的类?假设我有 spring 上下文,其中加载并实例化了几个类,并且我想更改其中一个类中的方法。
一般来说,该类会被替换、重新加载,并且每个其他实例都会从该类的新版本进行实例化。我想即使是旧的实例也被旧的实例取代了?
使用Spring时这也有效吗?这样我就有了一个 mvc 控制器并且我改变了它的方法?
或者我是否必须使用 JRebel 来满足此要求。
could please anybody share his experience about this topic ?
When using jpda on tomcat, does class reloading work even for classes loaded via spring ? Let say that I have spring context with couple of classes loaded and instantiated and I want to change a method in one of them.
In general, the class is replaced, reloaded and every other instance is instantiated from the new version of the class. I suppose that even the old instances are replaced with the old ones ?
Does this also work when Spring is used ? So that I have a mvc controller and I change its method ?
Or do I have to use JRebel for this requirement.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我的经验是,它运行良好且可靠,前提是您当然不更改方法签名、添加字段等。更改 spring 容器(包括 MVC 控制器)中任何类的任何现有方法的实现应该完全有效正如预期的那样。作为参考,我上次测试它是使用 Tomcat 6、Spring 3 并通过远程连接的调试器使用 Netbeans 6.9 的“应用代码更改”,但它是 Java 标准,所以我怀疑 IDE 会对其产生很大影响。
编辑:以上都不涉及 JRebel (我从未使用过它)。
My experience with this is that it works well and reliably, provided you don't of course change the method signature, add fields etc. Changing the implementation of any existing method of any class in the spring container (MVC controllers included) should work entirely as expected. For reference, the last time I tested this was with Tomcat 6, Spring 3 and using Netbeans 6.9's "Apply Code Changes" over a remote attached debugger, but it's Java standard so I doubt the IDE will effect it much.
EDIT: None of the above concerns JRebel (I've never used it).