Java Eclipse—如何将一个项目作为Maven依赖项添加到另一个项目,而不是作为jar添加?
我有两个Maven项目。一个应该是对另一个的依赖。两者都有pom.xml文件。当我搜索存储库时,它会看到本地项目并自动添加 添加pom.xml条目时:Java Eclipse—如何将一个项目作为Maven依赖项添加到另一个项目,而不是作为jar添加?,java,eclipse,maven,dependencies,dependency-management,Java,Eclipse,Maven,Dependencies,Dependency Management,我有两个Maven项目。一个应该是对另一个的依赖。两者都有pom.xml文件。当我搜索存储库时,它会看到本地项目并自动添加 添加pom.xml条目时: <dependencies> <dependency> // for another dependency, an external jar <groupId>..</groupId> <artifactId>..</artifactId&g
<dependencies>
<dependency> // for another dependency, an external jar
<groupId>..</groupId>
<artifactId>..</artifactId>
<version>...</version>
</dependency>
<dependency> // the one for other project which I want to add as dependency
<groupId>..</groupId>
<artifactId>..</artifactId>
<version>..</version>
</dependency>
</dependencies>
//对于另一个依赖项,外部jar
..
..
...
//我想添加为依赖项的另一个项目
..
..
..
但是对该项目的引用不能看到这些类。是否有某种特定的方法来实现这一点,而不是从存储库中添加?我建议您使用此方法,因为您注意到在dependent中所做的更改没有反映在父项目中 理想情况下,你应该遵循这一点
父项目->属性->Java构建路径->库->添加JAR->在同一工作区中选择依赖于您的项目->构建您可以使用
标记内的
标记设置依赖项的类型
<dependency>
<groupId>..</groupId>
<artifactId>..</artifactId>
<version>...</version>
<type>jar OR war OR ejb-client OR test-jar</type>
</dependency>
..
..
...
jar或war或ejb客户端或测试jar
type的默认值是jar您的pom.xml看起来怎么样?我添加了,请检查。我需要将此依赖项用作项目,而不是jar。出于某种原因,我不知道,这个项目中的一些方案文件在jar中是不可见的,但当项目是一个包含源代码的Eclipse项目时,它们是可见的。