[英]Imported Maven Project into Eclipse 3.7 (m2e 1.0) but src/main/java are not shown as source-package
I have a maven (3.0.4) multi-module build project which works on command line perfect. 我有一个Maven(3.0.4)多模块构建项目,可以在命令行完美环境下工作。
mvn clean package
build successful. 建立成功。
I've tried to import that project into Eclipse 我试图将该项目导入Eclipse
with m2e 1.0. 使用m2e 1.0。
but after it's ready i can't see a package folder nor the icon for src-folders (like src/main/java etc). 但准备好后,我看不到软件包文件夹或src文件夹的图标(如src / main / java等)。
But i would have expected to see something like the following: 但我本来希望看到以下内容:
Does someone has a hint what problem might be? 有人暗示可能是什么问题吗? Or ideas where to look for? 或在哪里寻找想法?
Update 更新资料
After boiling this down it might be caused by using a Java 1.7. 将其煮沸后,可能是由于使用Java 1.7引起的。 compiler which i have configurate like the following: 我有如下配置的编译器:
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
<executable>C:/Programme/Java/jdk1.7.0_05/bin/javac</executable>
<fork>true</fork>
</configuration>
</plugin>
...
Someone with experience in this area? 有人在这方面有经验吗?
It looks like your project doesn't have a Java nature. 看起来您的项目没有Java性质。 You can change this by right-clicking the project and going to 您可以通过右键单击项目并转到
Properties -> Project Facets -> Convert to faceted form 属性->项目构面->转换为构面形式
From there you can add a Java facet, which should do the job. 从那里可以添加一个Java方面,这应该可以完成工作。 I often find with this sort of thing that it's easier to just edit Eclipse's .project
and .classpath
files manually (make sure to back them up before you do though!) instead. 我经常发现,通过这种方式手动编辑Eclipse的.project
和.classpath
文件会更容易(一定要先备份它们!)。 You'll probably want to check that your project's .project
file includes something like this: 您可能需要检查项目的.project
文件是否包含以下内容:
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
...
<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.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
Then make sure your .classpath
looks something like this: 然后确保您的.classpath
看起来像这样:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
...
<classpathentry kind="src" output="target/classes" path="src/main/java"/>
<classpathentry excluding="**" kind="src" path="src/main/resources"/>
<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
Once you've got all this stuff ready to go, update your project configuration like Michal said and refresh. 准备好所有这些内容之后,请像Michal所说的那样更新项目配置并刷新。
After long fiddling around i've found the problem which solves it for me: 经过长时间的摆弄,我发现了为我解决的问题:
I had a wrong lifecycle mapping for the maven-compiler-plugin (2.5.1) in my configuration which caused the problems. 我的配置中的maven-compiler-plugin(2.5.1)的生命周期映射错误,这导致了问题。 After removing it it works as expected no need to change the facets manually just import the project and it works. 删除后,它可以按预期工作,而无需手动更改构面,只需导入项目即可。
In your eclipse, it might be pointing to JRE
instead of JDK
. 在您的日食中,它可能指向JRE
而不是JDK
。 Go to window->preference->java->Installed JRE
. 转到window->preference->java->Installed JRE
。 Add JDK here, and set it to default. 在此处添加JDK,并将其设置为默认值。 You may need to restart eclipse. 您可能需要重新启动Eclipse。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.