maven package of resource configuration

 

          By default, if no resources, now that the auto will .xml files under src / main / resources into the file in the package target inside the classes folder under the folder.
If you set up resources, then the default will fail, and therefore needs to be set to specify the resources folder.

       Using the properties file copy, you can copy some files to a specified directory. However, be sure to specify the resources file directory, and then specify the file to be copied.

note:

        Under normal circumstances, we use resource files (various xml, properites, xsd files, etc.) are placed in src / main / resources below, take advantage of a package maven, maven can turn to the appropriate resource files are packaged in jar or war .
        Sometimes, such as mybatis of mapper.xml file, we are used to it and Mapper.java put together, in src / main / java below, so take advantage of maven package, we need to modify the pom.xml file to the mapper.xml with files packaged into jar or war where, otherwise, these files will not be packaged. (Maven source path that src / main / java only the java)

       <resources>
            <resource>
                <directory>${basedir}/src/main/java</directory>
                <includes>
                    <!-- **表示任意层路径,*表示任意名称-->
                    <include>**/*.xml</include>
                </includes>
                <filtering>false</filtering>
            </resource>
            <resource>
                <directory>${basedir}/src/main/resources</directory>
                <excludes>
                    <exclude>/sql/*</exclude>
                </excludes>
            </resource>
        </resources>

Standard Maven project directory structure

Apache Maven Resources Plugin

Reference links:

1.https://blog.csdn.net/u011781521/article/details/79052725

2.https://www.cnblogs.com/liuxm2017/p/10688789.html

3.https://www.bbsmax.com/A/kjdwqOMwJN/

发布了100 篇原创文章 · 获赞 47 · 访问量 21万+

Guess you like

Origin blog.csdn.net/sl1990129/article/details/103991059