英文:
How to change source code in maven dependency?
问题
我有一个包含许多依赖项的Maven项目,其中一个依赖我想要打印到控制台的称为 pulsar-log4j2-appender
。我尝试通过以下步骤在Intellij中打开相关的 .class 文件:
External Libraries | Maven:org.apache.pulsar:pulsar-log4j2-appender:2.6.0 | pulsar-log4j2-appender-2.6.0.jar | org.apache.pulsar.log4j2.appender | PulsarManager.class
当我尝试添加一个 System.out.println 语句时,Intellij显示该文件是只读的:
英文:
I have a maven project with a bunch of dependencies, one of which I'd like to print a line to console to called pulsar-log4j2-appender
. I tried opening the .class file in question by following in Intellij:
External Libraries | Maven: org.apache.pulsar:pulsar-log4j2-appender:2.6.0 | pulsar-log4j2-appender-2.6.0.jar | org.apache.pulsar.log4j2.appender | PulsarManager.class
When I try to add a System.out.println statement, Intellij says the file is read only:
答案1
得分: 6
你无法更改外部Maven依赖中的代码。
不过你可以使用集成开发环境的调试器对其进行调试,并监视你感兴趣的变量值。
如果你真的想要修改代码,你需要找到该项目(比如在GitHub上),将其检出并自行构建。
英文:
You cannot change code in external Maven dependencies.
You can debug them, though, with the debugger of your IDE and watch the values you are interested in.
If you really want to change the code, you need to find the project (e.g. on Github), check it out and build it yourself.
答案2
得分: 3
由Java字节码反编译插件提供支持,IntelliJ将Java字节码反编译为可读的Java代码,当您尝试打开.class
扩展文件时。
现在,您实际上正在查看Java反编译的字节码(无法在IDE内部编辑),而不是实际的Java代码(.java
扩展名)。
解决方案是修改源代码本身并重新构建。
更多信息:https://blog.jetbrains.com/idea/2020/03/java-bytecode-decompiler/
英文:
Powered by Java bytecode decompiler plugin, IntelliJ decompiles Java bytecode into human-readable Java code When you try to open .class
extension
Now, you're actually viewing Java decompiled bytecode(can't be edited inside the IDE), not actual Java code (.java
extension).
The solution would be to modify the source code itself and rebuild it.
More info: https://blog.jetbrains.com/idea/2020/03/java-bytecode-decompiler/
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论