【发布时间】:2019-08-09 13:10:26
【问题描述】:
我正在使用 maven 3.6.0 并在 POM 文件中使用 maven eclipse 插件来生成 eclipse .classpath(用于我的依赖项)文件。构建成功完成,当我尝试配置 eclipse 项目时。我遇到了构建路径错误,例如 1. jar 不存在于类路径中,但 jar 存在于 lib 文件夹中 2.期望jar版本不同,但lib中的版本不同
而不是使用 maven 创建 .classpath。我在本地创建了一个并将其作为资源复制到我的 eclipse 项目中。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.10</version>
<configuration>
<excludes>
<exclude>org.testng:testng</exclude>
<exclude>com.beust:jcommander</exclude>
<exclude>org.yaml:snakeyaml</exclude>
<exclude>org.apache-extras.beanshell:bsh</exclude>
</excludes>
</configuration>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>eclipse</goal>
</goals>
</execution>
</executions>
</plugin>
<execution>
<id>copy-eclipse-deps</id>
<phase>package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${setupDir}/Engine</outputDirectory>
<overWriteIfNewer>true</overWriteIfNewer>
<resources>
<resource>
<directory>${project.basedir}</directory>
<includes>
<include>.classpath</include>
<include>.project</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
目前我刚刚注释掉 .classpath 行并通过更正所有类路径错误将文件复制为资源。
我想通过 maven 本身来实现它,否则每次我引入第三方 jar 时,我最终都会在类路径中添加新条目。
【问题讨论】:
-
不要再使用 maven-eclipse-plugin 因为它已经退役了maven.apache.org/plugins/maven-eclipse-plugin 在 Eclipse 中通过 M2E 使用导入等。
标签: maven maven-eclipse-plugin