问题描述
假设存在Maven项目A和Maven项目B.项目B在其pom.xml中定义了对A的依赖关系:
Suppose there is Maven Project A and Maven Project B. Project B has defined a dependency on A in its pom.xml:
<dependency>
<groupId>com.company</groupId>
<artifactId>project-a</artifactId>
<version>0.1-SNAPSHOT</version>
</dependency>
现在在IntelliJ idea中打开两个项目(两个单独的窗口).
Now open both projects in IntelliJ idea (two separate windows).
在项目A中重构方法的最佳方法是什么?
What is the best way to refactor a method in project A?
当前,我在A中进行重构,并为其调用"mvn install",然后在项目B中进行搜索和替换,这样就可以了.但是有更快的东西吗?在NetBeans中,我只打开了两个项目,重构将应用于所有打开的项目.
Currently I do the refactoring in A and call "mvn install" for it, then do search&replace in project B and this works okayish. But is there something faster? In NetBeans I just open both projects and the refactoring will be applied to all open projects.
推荐答案
最好的方法是导入父Maven pom.xml
,它定义模块之间的依赖关系.这样,您将同时在IntelliJ IDEA中打开两个模块,并且重构将在整个项目中起作用.
The best way is it import the parent Maven pom.xml
which defines the dependencies between the modules. This way you will have both modules open in IntelliJ IDEA at the same time and the refactorings will work across the project.
这篇关于在IntelliJ中跨两个Java项目进行重构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!