why xml files in eclipse project's source directory is not copied to target/classes directory?

老子叫甜甜 提交于 2019-11-29 07:43:38
yorkw

Maven is by default looking for resource files i.e. *.xml, *.properties and etc. in src/main/resources directory. It is recommended to put your resource files under here.

However, nothing prevent you from putting resource files somewhere else, for instance, src/main/java/org/wpse/db/config/, as some people prefer to put resource files along with class file under special package, you just need a little more configuration in pom.xml:

<build>
  <resources>
    <resource>
      <!-- This include everything else under src/main/java directory -->
      <directory>${basedir}/src/main/java</directory>
      <excludes>
        <exclude>**/*.java</exclude>
      </excludes>
    </resource>
  </resources>

  ... ...
</build>

Related question: how to customize maven to generate the .classpath that i want?

By default configuration, when running mvn eclipse:eclipse it generates following .classpath file:

<classpath>
  <classpathentry kind="src" path="src/main/java" including="**/*.java"/>
  ... ...
</classpath>
... ...

When importing into Eclipse, it gives you following classpath (what you don't want):

Using the pom configuration above, when running 'mvn eclipse:eclipse' it generates following .classpath file:

<classpath>
  <classpathentry kind="src" path="src/main/java"/>
  ... ...
</classpath>
... ...

When importing into Eclipse, it gives you follwing classpath (what you want):

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!