为什么在运行maven阶段时未执行关联的目标
下面是我的maven插件maven依赖插件和与phase包相关的目标 我认为如果我运行命令mvn包,应该执行目标(dependecy:copy dependencies),因为这个目标与阶段包关联,但它不运行。谁能给我一些提示吗为什么在运行maven阶段时未执行关联的目标,maven,maven-dependency-plugin,Maven,Maven Dependency Plugin,下面是我的maven插件maven依赖插件和与phase包相关的目标 我认为如果我运行命令mvn包,应该执行目标(dependecy:copy dependencies),因为这个目标与阶段包关联,但它不运行。谁能给我一些提示吗 <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependen
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
</execution>
</executions>
</plugin>
org.apache.maven.plugins
maven依赖插件
2.8
包裹
复制依赖项
#
http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
<groupId>com.test</groupId>
<artifactId>abc</artifactId>
<version>1.0-SNAPSHOT</version>
<name>abc</name>
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.apache.kafka/kafka -->
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka_2.11</artifactId>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-streams</artifactId>
<version>1.0.1</version>
</dependency>
<!--dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.25</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.25</version>
</dependency-->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<plugin>
<!-- mvn clean compile assembly:single -->
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>de.dbschenker.rail.sresb.messages.util.KafkaStreamsApp</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.0.0</version>
</plugin>
<!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20.1</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
com.test
abc
1.0-快照
abc
http://www.example.com
UTF-8
1.8
1.8
org.apache.kafka
卡夫卡2.11
1.0.1
org.apache.kafka
卡夫卡河
1.0.1
朱尼特
朱尼特
4.11
测试
maven汇编插件
de.dbschenker.rail.sresb.messages.util.KafkaStreamsApp
带有依赖项的jar
maven清洁插件
3.0.0
maven资源插件
3.0.2
maven编译器插件
3.7.0
maven surefire插件
2.20.1
maven jar插件
3.0.2
maven安装插件
2.5.2
maven部署插件
2.8.2
org.apache.maven.plugins
maven依赖插件
2.8
包裹
复制依赖项
问题仅仅是因为您在pluginManagement区域中找到了maven依赖插件,而该插件不会真正执行插件 应该是这样的:
<project>
[...]
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<!-- configure the plugin here -->
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
[...]
</project>
[...]
org.apache.maven.plugins
maven依赖插件
3.1.1
复制依赖项
包裹
复制依赖项
[...]
pluginManagement区域旨在定义版本和配置,而不是执行本身
除此之外,我不认为您需要此配置,因为您已经在使用maven assembly插件。第一个问题:为什么需要此配置?我需要将所有依赖项JAR复制到一个单独的目录这是我根据给定的配置所理解的。但我想知道您为什么要这样做?什么类型f你想解决的问题?你能给出项目或者至少完整的pom文件吗?我还有第二个@khmarbaise问题。请详细说明。我使用maven dependency plugin的原因,因为我需要将所有dependency JAR复制到单独的文件夹中作为lib目录,以及我已经在这里提供的整个pom文件。maven-assembly-plugin package all依赖库,工件作为一个jar。但是依赖插件可以将所有依赖库复制到单独的文件夹中。
<project>
[...]
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<!-- configure the plugin here -->
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
[...]
</project>