Java Intellij maven模块继承
我已经阅读了文档,但仍然无法实现我想要实现的目标。要求很简单。我有两个maven项目ProjectA和ProjectBProjectB需要重用ProjectA中的一些常见配置和代码。我不想只是复制和粘贴它们,因为这将需要更新,如果有任何变化。那么,现在有什么选择呢?如何实现这一点?您可能有两种选择Java Intellij maven模块继承,java,maven,intellij-idea,Java,Maven,Intellij Idea,我已经阅读了文档,但仍然无法实现我想要实现的目标。要求很简单。我有两个maven项目ProjectA和ProjectBProjectB需要重用ProjectA中的一些常见配置和代码。我不想只是复制和粘贴它们,因为这将需要更新,如果有任何变化。那么,现在有什么选择呢?如何实现这一点?您可能有两种选择 使用您的项目A有您的项目B的父项 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 <parent> <groupI
- 使用您的项目A有您的项目B的父项
http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
<parent> <groupId>com.example</groupId> <artifactId>projectA</artifactId> <version>1.0</version> </parent> <artifactId>projectB</artifactId>
<artifactId>projectB</artifactId> <dependencies> <dependency> <groupId>com.example</groupId> <artifactId>projectA</artifactId> <version>1.0</version> </dependency> </dependencies>
因此,您的项目b将继承第一个项目及其所有依赖项构建/依赖项管理com.example 项目A 1 项目B
- 使用您的项目A与您的项目B有依赖关系
http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
<parent> <groupId>com.example</groupId> <artifactId>projectA</artifactId> <version>1.0</version> </parent> <artifactId>projectB</artifactId>
<artifactId>projectB</artifactId> <dependencies> <dependency> <groupId>com.example</groupId> <artifactId>projectA</artifactId> <version>1.0</version> </dependency> </dependencies>
projectB com.example 项目A 1
在这种情况下,projectB将从projectA继承所有源和依赖项。您可能有两个选项
- 使用您的项目A有您的项目B的父项
http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
<parent> <groupId>com.example</groupId> <artifactId>projectA</artifactId> <version>1.0</version> </parent> <artifactId>projectB</artifactId>
<artifactId>projectB</artifactId> <dependencies> <dependency> <groupId>com.example</groupId> <artifactId>projectA</artifactId> <version>1.0</version> </dependency> </dependencies>
因此,您的项目b将继承第一个项目及其所有依赖项构建/依赖项管理com.example 项目A 1 项目B
- 使用您的项目A与您的项目B有依赖关系
http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
<parent> <groupId>com.example</groupId> <artifactId>projectA</artifactId> <version>1.0</version> </parent> <artifactId>projectB</artifactId>
<artifactId>projectB</artifactId> <dependencies> <dependency> <groupId>com.example</groupId> <artifactId>projectA</artifactId> <version>1.0</version> </dependency> </dependencies>
projectB com.example 项目A 1
在这种情况下,projectB将继承projectA所有的源和依赖项。我认为没有解决这个问题的灵丹妙药,但我们使用这两种方法的组合:
我不认为这有什么灵丹妙药,但我们使用这两种方法的组合:
我创建了一个多模块maven项目,但总是在编译时找不到包。最终,我发现了这个问题
org.springframework.boot
springbootmaven插件
重新包装
执行官
我创建了一个多模块maven项目,但它总是在编译时找不到包。最终,我发现了这个问题
org.springframework.boot
springbootmaven插件
重新包装
执行官
非常感谢您提供的信息。第一种方法不起作用。作为依赖项添加模块是可行的,但当我运行mvn安装时,它说包com.email.model不存在,这在intellij的编译时可用。非常感谢您提供的信息。第一种方法不起作用。作为依赖项添加模块是可行的,但当我运行mvn安装时,它说包com.email.model不存在,这在intellij的编译时可用。