And*_*oso 28 eclipse classpath maven
我有一个maven项目,我正在研究Eclipse.
我使用maven eclipse:eclipse来生成类路径,但是......它永远不会在eclipse项目中添加类路径.我已经尝试了maven-eclipse-plugin,我已经尝试了M2Eclipse插件,但是无论我做什么都没关系,我无法让classpath条目开始工作.我有很多构建错误,甚至认为maven完美地构建了耳朵.
任何准则?
谢谢你的回答!
更新:这是我的根类路径:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="core/src/main/java"/>
<classpathentry excluding="**" kind="src" output="target/classes" path="core/src/main/resources"/>
<classpathentry kind="src" path="client/src/main/java"/>
<classpathentry kind="src" path="client/src/main/resources"/>
<classpathentry kind="src" path="junit_server/src/main/java"/>
<classpathentry kind="src" path="initializer/src/main/java"/>
<classpathentry kind="src" path="initializer/src/main/webapp"/>
<classpathentry kind="src" path="site/src/main/webapp"/>
<classpathentry kind="src" path="core/src/test/java"/>
<classpathentry kind="src" path="core/src/test/resources"/>
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry exported="true" kind="var" path="M2_REPO"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
Run Code Online (Sandbox Code Playgroud)
UPDATE2:这是我的.project:
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>coreisp_back</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
Run Code Online (Sandbox Code Playgroud)
Nic*_*tti 16
Maven Eclipse插件生成的设置与m2e/m2eclipse不兼容.如果你想一起使用Maven和Eclipse,最好的方法是删除maven eclipse插件生成的设置的任何修改,并使用m2e导入你的Maven项目.

您需要使用build-helper-maven-plugin将额外的源文件夹添加到pom.xml.然后跑
mvn eclipse:清除日食:日蚀
例如这个pom.xml ..
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>mygroup</groupId>
<artifactId>artifact</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>artifact</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>client/src/main/java</source>
</sources>
</configuration>
</execution>
<execution>
<id>add-resource</id>
<phase>generate-resources</phase>
<goals>
<goal>add-resource</goal>
</goals>
<configuration>
<resources>
<resource>
<directory>client/src/main/resources</directory>
<targetPath>resources</targetPath>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Run Code Online (Sandbox Code Playgroud)
生成此.classpath
<classpath>
<classpathentry kind="src" path="src/test/java" output="target/test-classes" including="**/*.java"/>
<classpathentry kind="src" path="src/main/java" including="**/*.java"/>
<classpathentry kind="src" path="client/src/main/java" including="**/*.java"/>
<classpathentry kind="src" path="client/src/main/resources" excluding="**/*.java"/>
<classpathentry kind="output" path="target/classes"/>
<classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
</classpath>
Run Code Online (Sandbox Code Playgroud)
确保文件夹存在,如果路径不正确,则不会添加.在maven日志中查找.
[INFO]跳过不存在的resourceDirectory/tmp/artifact/src/main/resources
我的团队发现eclipse maven插件不稳定,选择通过maven创建我们的整个eclipse配置.
| 归档时间: |
|
| 查看次数: |
85506 次 |
| 最近记录: |