我有一个已经在另一台机器上构建的maven插件jar,比如test-1.0.0.jar。这个jar有多个依赖,如apache,plexus,maven等。 e.g。
<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>
现在我想将这个jar用于我的maven项目,所以我将它安装在我的本地存储库中。当我使用'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>
答案 0 :(得分:0)
您应该将test-1.0.0.jar
依赖项添加到pom.xml <dependencies>
。
使用-U
参数执行maven应该强制检查远程存储库中缺少的版本和更新的快照。例如:
mvn -U clean install
实际执行目标dependency:resolve
只会下载依赖项而不做其他事情。
mvn dependency:resolve
答案 1 :(得分:0)
尝试将test-1.0.0.jar中的依赖项添加到您的maven项目中。
(pom.xml) test-1.0.0.jar ---copy dependencies---> new maven project