Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Files in src/main/resources not copied when using maven and eclipse

I use maven and eclipse (with m2eclipse) for Java projects. I usually start with

$ mvn archetype:create \
  -DarchetypeGroupId=org.apache.maven.archetypes \
  -DgroupId=com.whatever.app \
  -DartifactId=wonderapp
$ mvn eclipse:eclipse

and then import the project into eclipse. The build path in eclipse now contains an "Excluded: **" pattern for the src/main/resource path. If I put for example the log4j.properties file in src/main/resources, it will not be copied to the output path and hence log4j won't work properly.


(source: skitch.com)

After I ran mvn eclipse:eclipse, the .classpath file in the root directory contains this line:

<classpathentry kind="src" path="src/main/resources" excluding="**/*.java"/>

After importing in eclipse, it has changed to:

<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>

I end up having to manually remove the "**" pattern. Is there any way so that I don't have to do this?

like image 961
ubiyubix Avatar asked Oct 02 '10 15:10

ubiyubix


People also ask

How do I create a src main resources folder?

by clicking properties or directly build path button. Click on source tab and then click on add folder and browse the resources folder and add that's all.

What is SRC main Java in Maven?

The src/main Directory As the name indicates, src/main is the most important directory of a Maven project. Anything that is supposed to be part of an artifact, be it a jar or war, should be present here. Its subdirectories are: src/main/java – Java source code for the artifact.

What is resources folder in Maven project?

Maven resources folder is used to store all your project resources files like , xml files, images, text files and etc. The default Maven resources folder is located at “yourproject/src/main/resources“.


1 Answers

I use maven and eclipse (with m2eclipse) for Java projects. I usually start with (...) and then import the project into eclipse.

Why do you use mvn eclipse:eclipse with m2eclipse? Just create your project and then Import... > Existing Maven Project.

like image 137
Pascal Thivent Avatar answered Oct 07 '22 18:10

Pascal Thivent