【发布时间】:2017-03-06 10:38:46
【问题描述】:
我有一个已经在另一台机器上构建的 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>
现在我想将这个 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>
【问题讨论】:
-
不能直接运行
mvn clean install来安装吗? -
no.. 我没有代码库.. 我刚刚安装了 jar(使用 mvn clean install),我需要将它安装在我的本地仓库中
-
但这正是
mvn install所做的... -
我正在使用 -'mvn install:install-file -Dfile=test-1.0.0.jar -DgroupId=com.test.status -DartifactId=test -Dversion= 在本地 repo 中安装 jar 文件1.0.0 -Dpackaging=maven-plugin' command .. 它会下载一些依赖项,但不是全部..
-
请提供有关
classNotFound异常的更多信息。
标签: java maven jar dependencies