mapper-locations 对应的 value 的配置

mapper-locations 对应的 value 的配置

情况描述:

想要将 *Mapper.xml 都放在 java 下的相应的包中

在这个路径上,也被折磨了很久,java 目录也是我们自己创建的,但是配置路径只需要从 java 下面的目录开始配置,前面使用 classpath*: 代替

配置方式一:

正确配置路径:

比如:
我的 Mapper.xml 文件在 com.xpwi.mapper 包下,

这样配置:

<property name="mapperLocations" value="classpath*:com/xpwi/mapper/*Mapper.xml"></property>

截图:

mapper-locations 对应的 value 的配置

配置方式二:

使用变量的形式在 properties 文件中定义(需要加载那个 properties 文件):

(1)config.properties 文件:

mapper-locations = classpath*:com/xpwi/mapper/*.xml

(2)路径配置:

<property name="mapperLocations" value="${mapper-locations}"></property>

多个 xml 文件的配置

<property name="mapperLocations" >
	<list>
		<value>classpath*:/sqlmap/*.xml</value>
		<value>classpath*:/test/*.xml</value>
	</list>
</property>

更多爬坑记录