IDEA adds Mapper.xml file template


Preface

In the process of learning the MyBatis framework, I found that it is impossible to create a Mapper.xml mapping file in the idea. The created xml file does not have the basic format of the Mapper.xml file. This article describes how to create a Mapper.xml mapping file template in the idea.


Tip: The following is the content of this article

Steps to create xml file:

1. Find the location where the xml file template is defined in idea

File → Settings… → Editor → File and Code Templates

Insert picture description here
Insert picture description here

2. Define the file and edit the template

Click the "+" sign, and enter the name of the file and the type of the file. After editing the template, click Apply to create it successfully
Insert picture description here
Insert picture description here

3. Mapper.xml file template

<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" 
"http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="">
    
</mapper>

Additional: mybatis-config.xml template

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
        PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-config.dtd">
    
<configuration>
    
</configuration>

Insert picture description here
Insert picture description here

to sum up

The above is how to create a Mapper.xml file template in idea. Secondly, in the MyBatis framework, idea also needs to use the same method to create a corresponding template when creating a mybatis-config.xml file.

Guess you like

Origin blog.csdn.net/qq_48455576/article/details/113838269