Method 1 puts the xml file and the mapper class together.
yml configuration
mybatis:
config-location: classpath:mybatis-config.xml
mapper-locations: classpath:com/example/pgsqldemo/mybatis/dao/xml/*.xml
# mapper-locations: classpath:static/mybatis/mapper/*.xml
pom.xml configuration
<build>
<resources>
<!-- 扫描src/main/java下所有xx.xml文件 -->
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
<!-- 扫描resources下所有资源 -->
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
</build>
Method 2: resources creates a folder with the same name as the Mapper interface to store the Mapper.xml file (mybatis default method)
yml configuration
mybatis:
config-location: classpath:mybatis-config.xml
Method 3 Create a custom folder in the resources directory for storage
yml configuration
mybatis:
config-location: classpath:mybatis-config.xml
mapper-locations: classpath:/mapper/*.xml