知识养成了思想,思想同时又在融化知识。这篇文章主要讲述[MyBatis]mapperLocations属性通配符的使用相关的知识,希望能为你提供帮助。
mapperLocations属性通配符的使用
示例:
[html] view plain copy print?
- < bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
- < property name="dataSource" ref="dataSource" />
- < property name="configLocation" value="https://www.songbingjia.com/android/classpath:sqlMapConfig.xml"> < /property>
- < property name="mapperLocations" value="https://www.songbingjia.com/android/classpath*:com/huaxin/**/*Mapper.xml"> < /property>
- < /bean>
< bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> < property name="dataSource" ref="dataSource" /> < property name="configLocation" value="https://www.songbingjia.com/android/classpath:sqlMapConfig.xml"> < /property> < property name="mapperLocations" value="https://www.songbingjia.com/android/classpath*:com/huaxin/**/*Mapper.xml"> < /property> < /bean>
注意点:在classpath后面的*必不可少,缺少型号的话后面的通配符不起作用。【[MyBatis]mapperLocations属性通配符的使用】 **表示可以表示任意多级目录,如:上述配置可以查到【com/huaxin/framework/system/dao/UserDaoMapper.xml】
*表示多个任意字符
缺少classpath后面的*会报以下的错误:
[plain] view plain copy print?
- org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
- ### Error querying database. Cause: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for framework.system.dao.UserDao.getNextUserId_mysql
- ### Cause: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for framework.system.dao.UserDao.getNextUserId_MySQL
- at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:75)
- at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:371)
- at com.sun.proxy.$Proxy18.selectOne(Unknown Source)
- at org.mybatis.spring.SqlSessionTemplate.selectOne(SqlSessionTemplate.java:163)
- at com.huaxin.framework.core.dao.impl.BaseDaoImpl.selectOne(BaseDaoImpl.java:298)
- at com.huaxin.framework.system.dao.impl.UserDaoImpl.getNextUserId(UserDaoImpl.java:41)
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: ### Error querying database.Cause: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for framework.system.dao.UserDao.getNextUserId_MySQL### Cause: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for framework.system.dao.UserDao.getNextUserId_MySQLat org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:75)at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:371)at com.sun.proxy.$Proxy18.selectOne(Unknown Source)at org.mybatis.spring.SqlSessionTemplate.selectOne(SqlSessionTemplate.java:163)at com.huaxin.framework.core.dao.impl.BaseDaoImpl.selectOne(BaseDaoImpl.java:298)at com.huaxin.framework.system.dao.impl.UserDaoImpl.getNextUserId(UserDaoImpl.java:41)
推荐阅读
- 行业洞察(旅游APP软件开发未来发展走向)
- Android ProgressBar手动控制开始和停止
- 可集成到APP的车架号识别sdk
- DataGuard apply比较慢
- Android Service的全面解析
- swappiness参数设置与内存交换
- Linux Shell命令
- Linux alias命令
- Linux Sed正则表达式