我有一个maven插件jar,它已经构建在另一台机器上,比如test-1.0.0.jar。这个jar有多个依赖项,如apache、plexus、maven等。例如:
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>3.3.9</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>3.3.9</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-compat</artifactId>
<version>3.3.9</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-embedder</artifactId>
<version>3.3.9</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-archiver</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>3.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>maven-surefire-common</artifactId>
<version>2.19.1</version>
</dependency>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-api</artifactId>
<version>2.19.1</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-component-annotations</artifactId>
<version>1.6</version>
</dependency>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>2.19.1</version>
</dependency>
</dependencies>现在我想在我的maven项目中使用这个jar,所以我将它安装到了我的本地存储库中。当我使用'mvn install: install -file‘命令安装它时,它没有下载m2存储库中jar所需的所有依赖项。所以当我在我的新maven项目中使用这个插件时,它会给我一个classNotFound异常。
[WARNING] Error injecting: com.test.status.test.MyTestCompileMojo
java.lang.NoClassDefFoundError: org/codehaus/plexus/compiler/util/scan/InclusionScanException我的项目POM -
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.check.status</groupId>
<artifactId>cf</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<build>
<plugins>
<plugin>
<groupId>com.test.status</groupId>
<artifactId>test</artifactId>
<version>1.0.0</version>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
<dependencies/>
</project>发布于 2017-03-06 18:44:40
您应该将test-1.0.0.jar依赖项添加到pom.xml <dependencies>中。
使用-U参数执行maven应该会强制检查远程存储库上缺少的版本和更新的快照。例如:
mvn -U clean install实际上,执行目标dependency:resolve只会下载依赖项,而不会做任何其他事情。
mvn dependency:resolve发布于 2017-03-06 18:50:58
尝试将test-1.0.0.jar中的依赖项添加到maven项目中。
(pom.xml) test-1.0.0.jar ---copy dependencies---> new maven projecthttps://stackoverflow.com/questions/42623412
复制相似问题