使用自定义类加载器时覆盖 IntelliJ 中的调试类路径
我正在调试 IntelliJ 中的一个项目,该项目使用多个类加载器。我有许多作为 JAR 包含的库,用于编译。当我调试时,我想在没有类路径的情况下启动 JVM,因为我的依赖项是由我的自定义类加载器加载的。
但 IntelliJ 会自动构建默认类路径并将其传递给 JVM。我找不到一种方法来覆盖这种行为。是否可以强制以空类路径开头的调试配置?
谢谢, 乔恩
I'm debugging a project in IntelliJ which uses multiple ClassLoaders. I have a number of libraries included as JARs which are used for compilation. When I debug I want to start the JVM with no classpath since my dependencies are loaded by my customized ClassLoaders.
But IntelliJ automatically builds the default classpath and passes this to the JVM. I can't find a way to override this behaviour. Is it possible to force a debug configuration which starts with an empty classpath?
Thanks,
Jon
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
可能的话,创建一个没有额外类路径元素的虚拟模块,并在运行/调试配置中指定该模块使用其类路径。
Possible, create a dummy module with no extra classpath elements and in the Run/Debug configuration specify this module to use the classpath of.
在运行配置中,您可以将“使用模块的类路径和依赖项”更改为无模块,但这并不能解决这个特定问题。
我认为您需要一个引导模块,其中仅包含启动环境所需的代码,并到达类加载器参与的位置,以及代码具有的任何依赖项,然后从该模块运行调试。我不能 100% 确定调试器会意识到这些类属于它所知道的源代码,但这将是我的第一次尝试。
In the run configuration, you can change the "Use Classpath and dependencies of Module" to no module, but that won't solve this particular problem.
I think you need a bootstrap module that has just the code that is needed to start up the environment and get to the point where your classloaders get involved, and whatever dependencies that code has, and then run the debug from that module. I'm not 100% sure that the debugger will realize that the classes belong to the source code that it knows about, but that would be my first try.