我有一个 maven 项目,我说 spring 框架库作为依赖项,我想将带有传递依赖项的 spring 框架依赖项复制到指定的位置。
我已经在 apache 浏览了 maven 依赖插件指南,我有几个选项,其中没有一个可以解决完整的问题。
- 复制依赖项选项
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <version>2.8</version> <executions> <execution> <id>copy-dependencies</id> <phase>package</phase> <goals> <goal>copy-dependencies</goal> </goals> <configuration> <outputDirectory>${project.build.directory}/alternateLocation</outputDirectory> <overWriteReleases>false</overWriteReleases> <overWriteSnapshots>false</overWriteSnapshots> <overWriteIfNewer>true</overWriteIfNewer> </configuration> </execution> </executions> </plugin>
这会将所有依赖项和传递项复制到给定位置,我只想要弹簧依赖项和传递项。
- 复制特定的工件
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <version>2.8</version> <executions> <execution> <id>copy</id> <phase>package</phase> <goals> <goal>copy</goal> </goals> <configuration> <artifactItems> <artifactItem> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>3.2.4.RELEASE</version> <type>jar</type> <overWrite>false</overWrite> <outputDirectory>${project.build.directory}/alternateLocation</outputDirectory> <destFileName>optional-new-name.jar</destFileName> </artifactItem> </artifactItems> <outputDirectory>${project.build.directory}/wars</outputDirectory> <overWriteReleases>false</overWriteReleases> <overWriteSnapshots>true</overWriteSnapshots> </configuration> </execution> </executions> </plugin>
这不应对传递依赖。
解决我这两个问题的任何解决方案。