K
K
Ki-Wi2015-08-11 12:56:06
Java
Ki-Wi, 2015-08-11 12:56:06

Why are there problems importing a Maven project into Eclipse?

Hello.
When importing a Maven project into Eclipse, there is a problem with the project structure. The project was created using the maven-webapp-archetype archetype . To add import capability to Eclipse I used mvn eclipse:eclipse. Everything seems to be ok in the .classpath file :

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
  <classpathentry kind="src" path="src/main/java" including="**/*.java"/>
  <classpathentry kind="src" path="src/main/resources" excluding="**/*.java"/>
  <classpathentry kind="output" path="target/classes"/>
  <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
  <classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar" sourcepath="M2_REPO/junit/junit/3.8.1/junit-3.8.1-sources.jar"/>
  <classpathentry kind="var" path="M2_REPO/org/springframework/spring-core/4.2.0.RELEASE/spring-core-4.2.0.RELEASE.jar" sourcepath="M2_REPO/org/springframework/spring-core/4.2.0.RELEASE/spring-core-4.2.0.RELEASE-sources.jar"/>
  <classpathentry kind="var" path="M2_REPO/org/springframework/spring-web/4.2.0.RELEASE/spring-web-4.2.0.RELEASE.jar" sourcepath="M2_REPO/org/springframework/spring-web/4.2.0.RELEASE/spring-web-4.2.0.RELEASE-sources.jar"/>
  <classpathentry kind="var" path="M2_REPO/org/springframework/spring-aop/4.2.0.RELEASE/spring-aop-4.2.0.RELEASE.jar" sourcepath="M2_REPO/org/springframework/spring-aop/4.2.0.RELEASE/spring-aop-4.2.0.RELEASE-sources.jar"/>
  <classpathentry kind="var" path="M2_REPO/aopalliance/aopalliance/1.0/aopalliance-1.0.jar" sourcepath="M2_REPO/aopalliance/aopalliance/1.0/aopalliance-1.0-sources.jar"/>
  <classpathentry kind="var" path="M2_REPO/org/springframework/spring-beans/4.2.0.RELEASE/spring-beans-4.2.0.RELEASE.jar" sourcepath="M2_REPO/org/springframework/spring-beans/4.2.0.RELEASE/spring-beans-4.2.0.RELEASE-sources.jar"/>
  <classpathentry kind="var" path="M2_REPO/org/springframework/spring-context/4.2.0.RELEASE/spring-context-4.2.0.RELEASE.jar" sourcepath="M2_REPO/org/springframework/spring-context/4.2.0.RELEASE/spring-context-4.2.0.RELEASE-sources.jar"/>
  <classpathentry kind="var" path="M2_REPO/org/springframework/spring-expression/4.2.0.RELEASE/spring-expression-4.2.0.RELEASE.jar" sourcepath="M2_REPO/org/springframework/spring-expression/4.2.0.RELEASE/spring-expression-4.2.0.RELEASE-sources.jar"/>
  <classpathentry kind="var" path="M2_REPO/org/springframework/spring-webmvc/4.2.0.RELEASE/spring-webmvc-4.2.0.RELEASE.jar" sourcepath="M2_REPO/org/springframework/spring-webmvc/4.2.0.RELEASE/spring-webmvc-4.2.0.RELEASE-sources.jar"/>
  <classpathentry kind="var" path="M2_REPO/ch/qos/logback/logback-classic/1.0.13/logback-classic-1.0.13.jar" sourcepath="M2_REPO/ch/qos/logback/logback-classic/1.0.13/logback-classic-1.0.13-sources.jar"/>
  <classpathentry kind="var" path="M2_REPO/ch/qos/logback/logback-core/1.0.13/logback-core-1.0.13.jar" sourcepath="M2_REPO/ch/qos/logback/logback-core/1.0.13/logback-core-1.0.13-sources.jar"/>
  <classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-api/1.7.5/slf4j-api-1.7.5.jar" sourcepath="M2_REPO/org/slf4j/slf4j-api/1.7.5/slf4j-api-1.7.5-sources.jar"/>
  <classpathentry kind="var" path="M2_REPO/org/slf4j/jcl-over-slf4j/1.7.5/jcl-over-slf4j-1.7.5.jar" sourcepath="M2_REPO/org/slf4j/jcl-over-slf4j/1.7.5/jcl-over-slf4j-1.7.5-sources.jar"/>
  <classpathentry kind="var" path="M2_REPO/jstl/jstl/1.2/jstl-1.2.jar"/>
</classpath>

The problem arises when I want to add a new class to src/main/java/ . Eclipse for some reason recognizes it as a resource and not source code. Through Maven, everything is fine and works.
I already tried to delete and import the project again - it did not help. What could be the reason and how to fix it? Thanks in advance.
UPD: The m2e plugin for Eclipse solved the problem: I managed to work with the project in Eclipse, but the issue of maven-eclipse-plugin is still open.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question