[Use of Mybatis]mapperlocations property wildcard characters

Source: Internet
Author: User

The use of Mapperlocations property wildcard characters

Example:

[HTML]View PlainCopyPrint?
  1. < Bean id="sqlsessionfactory" class=" Org.mybatis.spring.SqlSessionFactoryBean ">
  2. < Property name="DataSource" ref="DataSource" />
  3. < Property name="configlocation" value=" Classpath:sqlMapConfig.xml "></Property>
  4. < Property name="mapperlocations" value="classpath*: Com/huaxin/**/*mapper.xml "></Property>
  5. </ Bean >   
  <bean id= "Sqlsessionfactory" class= "Org.mybatis.spring.SqlSessionFactoryBean" >        <property name= " DataSource "ref=" DataSource "/>        <property name=" configlocation "value=" Classpath:sqlMapConfig.xml "> </property>        <property name= "mapperlocations" value= "Classpath*:com/huaxin/**/*mapper.xml" ></ Property>    </bean>

Note: The classpath behind the * is essential, and the following wildcard character does not work if a model is missing.

* * indicates that you can represent any multilevel directory, such as: The above configuration can be found "com/huaxin/framework/system/dao/userdaomapper.xml"

* Denotes multiple arbitrary characters


Missing Classpath * will report the following error:

[Plain]View PlainCopyPrint?
  1. Org.mybatis.spring.MyBatisSystemException:nested exception is org.apache.ibatis.exceptions.PersistenceException:
  2. # # # Error querying database. Cause:java.lang.IllegalArgumentException:Mapped Statements collection does not contain value for Framework.system.dao.UserDao.getNextUserId_MySQL
  3. # # # Cause:java.lang.IllegalArgumentException:Mapped Statements collection does not contain value for FRAMEWORK.SYSTEM.D Col Userdao.getnextuserid_mysql
  4. At Org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible (Mybatisexceptiontranslator.java : 75)
  5. At Org.mybatis.spring.sqlsessiontemplate$sqlsessioninterceptor.invoke (sqlsessiontemplate.java:371)
  6. At Com.sun.proxy. $Proxy 18.selectOne (Unknown Source)
  7. At Org.mybatis.spring.SqlSessionTemplate.selectOne (sqlsessiontemplate.java:163)
  8. At Com.huaxin.framework.core.dao.impl.BaseDaoImpl.selectOne (basedaoimpl.java:298)
  9.     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_MySQL at org.mybatis.spring.MyBatisEx Ceptiontranslator.translateexceptionifpossible (mybatisexceptiontranslator.java:75) at Org.mybatis.spring.sqlsessiontemplate$sqlsessioninterceptor.invoke (sqlsessiontemplate.java:371) at Com.sun.proxy . $Proxy 18.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)


[Use of Mybatis]mapperlocations property wildcard characters

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.