MAVEN package configuration files in Java

Source: Internet
Author: User

Forwarding Address http://www.cnblogs.com/liuzy2014/p/5981824.html

In general, the resource files we use (various xml,properites,xsd files, etc.) are placed under Src/main/resources, and MAVEN can package these resource files into the appropriate jar or war using MAVEN. Sometimes, such as MyBatis's Mapper.xml file, we used to put it and Mapper.java together, all under the Src/main/java, so using maven packaging, You will need to modify the Pom.xml file to package the Mapper.xml file into a jar or war, otherwise these files will not be packaged. (Maven thinks Src/main/java is just Java's source code path). There are many methods on the network, I probably tried, several methods can be, can choose one. Otherwise, the war package is not mapper.xml. Method 1, where **/* is written in order to ensure that the resource files under all levels of subdirectories are packaged. XML code Collection Code <build> <finalName>test</finalName> <!--This also allows you to package all of your XML files into corresponding location. <resources> <resource> <directory>src/main/resources</directory> <includes> <include>**/*.properties</include> &L T;include>**/*.xml</include> <include>**/*.tld</include> </i Ncludes> <filtering>false</filtering>--filtering is to indicate that the configuration file includes ${} This dynamic change should not be replaced by a true value, true means replacement, and WillThe file is packaged. False indicates no substitution. But once the include is written, it will certainly include the configuration file into the war </resource> <resource> <directory&gt ;src/main/java</directory> <includes> <include>**/*.properties< /include> <include>**/*.xml</include> <include>**/*.tld< /include> </includes> <filtering>false</filtering> &lt ;/resource> </resources> </build>

Maven Packages The configuration files in Java

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.