Sure, here’s the translation: Intellij:将项目作为库导入另一个项目

huangapple go评论62阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2020年10月7日 22:03:39
  • 转载请务必保留本文链接:https://go.coder-hub.com/64245752.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定