Home> Java> javaTutorial> body text

Problems encountered when maven integrates the framework with mybaits

巴扎黑
Release: 2017-06-26 10:39:29
Original
1790 people have browsed it

First, let’s take a look at the standard directory structure of the MAVENx project:

Generally, the resource files we use (various xml , properties, xsd files, etc.) are placed under src/main/resources. When using maven for packaging, maven can package these resource files into the corresponding jar or war.

Sometimes, for example, the mapper.xml file of mybatis, we are used to putting it together with Mapper.java, both under src/main/java. In this way, when using maven to package, You 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 that src/main/java is just the source code path of java). There are many methods on the Internet. I tried it out, and several methods are available. You can choose any one.

Method 1, where **/* is written in order to ensure that resource files in subdirectories at all levels are packaged.

xml code

Problems encountered when maven integrates the framework with mybaits
 test   src/main/java  **/*.properties **/*.xml **/*.tld  false  
Copy after login
Problems encountered when maven integrates the framework with mybaits

Method 2, using the build-helper-maven-plugin plugin

Problems encountered when maven integrates the framework with mybaits##
 ... ...   org.codehaus.mojo build-helper-maven-plugin 1.8   add-resource generate-resources  add-resource     src/main/java  **/*.xml        ... ... 
Copy after login
Problems encountered when maven integrates the framework with mybaits
Method 3, using the maven-resources-plugin plug-in

Problems encountered when maven integrates the framework with mybaits##
 ... ...   maven-resources-plugin 2.5   copy-xmls process-sources  copy-resources   ${basedir}/target/classes   ${basedir}/src/main/java  **/*.xml        ... ... 
Copy after login
Problems encountered when maven integrates the framework with mybaits

The above is the detailed content of Problems encountered when maven integrates the framework with mybaits. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!