1
我有一个Maven项目说“MyProject”,使用另一个项目作为普通的Maven依赖项,说我写的“MyDependency”。 MyDependency是一个maven项目,使用其他依赖项,如springframework,apache-commons,apache-camel等。我的maven项目可以从依赖关系中的pom中导入依赖项吗?
问题是这样的。我希望MyProject在MyDependency中查看传递依赖关系,而不必将它们再次添加到pom文件中。我尝试了maven-dependency插件和maven-jar插件来生成一个jar,如下所示,它包含它内的所有依赖关系,但没有结果。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.5.1</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<includeScope>compile</includeScope>
<outputDirectory>${project.build.directory}/classes/lib</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
</configuration>
</execution>
</executions>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.6</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
</manifest>
<manifestEntries>
<Class-Path>lib/</Class-Path>
</manifestEntries>
</archive>
<finalName>core-${project.version}</finalName>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
有没有办法做到这一点?或者我的问题都是错误的?
你是什么意思“我希望MyProject看到传递依赖”?如果你没有做任何不寻常的事情,这应该是开箱即用的。 – Daniel
是的,我知道它应该默认工作,但这不是实际发生的事情。 –
您是否在使用'MyDependency'的任何特定范围? – Daniel