Maven: Include resources into JAR

删除回忆录丶 提交于 2019-11-28 21:19:19

The source directories for the resources are not defined correctly in the copy-resources goal configuration. Also, the outputDirectory element puts the resources in the target dir, when target/classes is what gets packaged by default. Try this config:

<configuration>
    <outputDirectory>${basedir}/target/classes</outputDirectory>
    <includeEmptyDirs>true</includeEmptyDirs>
    <resources>
        <resource>
            <directory>${basedir}/src/main/java/com/test/customize</directory>
            <filtering>false</filtering>
        </resource>
        <resource>
            <directory>${basedir}/src/main/java/com/test/resources</directory>
            <filtering>false</filtering>
        </resource>
        <resource>
            <directory>${basedir}/src/main/java/com/test/xml</directory>
            <filtering>false</filtering>
        </resource>
    </resources>
</configuration>

That said, you might consider putting the resources in ${basedir}/src/main/resources, like so:

src
   main
      resources
         customize
         resources
         xml

Then, you could remove the extra maven-resources-plugin config entirely, the default lifecycle will process the resources correctly.

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