问题描述:

I was trying to use maven to build my project

when I create a source folder src/main/resource and put a file into that folder.

But when I do "mvn clean install eclipse:clean eclipse:eclipse", src/main/resource folder gone, it appears to the src folder instead

The problem of this new structure for me is that I have to manually create a src/main/resource folder again to make sure that those files in the resource folder could be deployed into classpath when I run it. I wonder if there is a way to let maven do it automatically for me? Thanks

网友答案:

You can specify the resources directory in pom.xml. Following is the example:

<build>
    <directory>target</directory>
    <outputDirectory>target/classes</outputDirectory>
    <finalName>${artifactId}-${version}</finalName>
    <testOutputDirectory>target/test-classes</testOutputDirectory>
    <sourceDirectory>src/main/java</sourceDirectory>
    <scriptSourceDirectory>src/main/scripts</scriptSourceDirectory>
    <testSourceDirectory>src/test/java</testSourceDirectory>
    <resources>
      <resource>
        <directory>src/main/resources</directory>
      </resource>
    </resources>
    <testResources>
      <testResource>
        <directory>src/test/resources</directory>
      </testResource>
    </testResources>
  </build>

reference: http://maven.apache.org/guides/introduction/introduction-to-the-pom.html

相关阅读:
Top