mapperLocations属性通配符classpath*

本文介绍了在Java中mapperLocations属性使用classpath*通配符的细节。指出`classpath*:com/huaxin/**/*Mapper.xml`是有效格式,而`classpath*:com/huaxin/**/*.xml`会导致错误。区别了classpath和classpath*,前者只在class路径中查找,后者包括class路径和jar文件。同时,通过例子说明了在不同层级的项目结构中,正确使用classpath*的重要性。
摘要由CSDN通过智能技术生成

在classpath后面的*必不可少,缺少型号的话后面的通配符不起作用。

            **表示可以表示任意多级目录,如:上述配置可以查到【com/huaxin/framework/system/dao/UserDaoMapper.xml】

            *表示多个任意字符

注意:value=“classpath*:com/huaxin/**/*Mapper.xml” ,.xml前面必须有字母.

如果写成 value=“classpath*:com/huaxin/**/*.xml” 会报错。


五月 14, 2021 9:31:49 下午 org.apache.ibatis.logging.commons.JakartaCommonsLoggingImpl warn
警告: Property 'mapperLocations' was specified but matching resources are not found.



org.apache.ibatis.binding.BindingException: Type interface com.jing.dao.UserMapper is not known to the MapperRegistry.

	at org.apache.ibatis.binding.MapperRegistry.getMapper(MapperRegistry.java:47)
	at org.apache.ibatis.session.Configuration.getMapper(Configuration.java:779)
	at org.mybatis.spring.SqlSessionTemplate.getMapper(SqlSessionTemplate.java:312)
	at com.jing.dao.UserDaoImpl.getUsers(UserDaoImpl.java:16)
	at com.jing.dao.MyTest.test1(MyTest
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值