英文:
Intellij : import project as library for another project
问题
我正在开发一个项目A(Java Maven),该项目使用一个库B(一个JAR文件)。
我拥有库B的源代码,并且我想在项目A将其作为库使用时更改库B中的代码。
在Intellij中是否可能通过其源代码替换一个JAR库?
英文:
I am developing a project A (Java Maven) which uses a library B (a JAR file)
I have the source code of library B, and I want to change code in project B, while it's used as library for project A.
Is that possible in Intellij to replace a JAR library by its source code ?
答案1
得分: 1
我会配置一个多模块的Maven项目,其中包括一个父级聚合pom.xml和2个子模块:一个用于应用程序,另一个用于库,它们各自都有自己的pom.xml文件。
在app模块中对lib模块进行依赖配置。IDE将通过源代码解析这些依赖项,您将立即在项目中看到更改,无需编译即可查看。重构也将跨模块工作,这样您可以从在app中的使用中重命名一个方法,它将自动在lib中重命名。
英文:
I'd configure a multi-module Maven project with the parent aggregate pom.xml and 2 sub-modules: for the app and for the library with their own pom.xml files.
Define a dependency on the lib module for the app module. IDE will resolve such dependencies via the sources and you will see the changes in the project instantly without the need to compile. Refactorings will also work across the modules so that you can rename a method from the usage in the app and it will automatically rename it in the lib.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论