[MyBatis]mapperLocations屬性萬用字元的使用

來源:互聯網
上載者:User

標籤:tor   isp   source   r.java   property   注意   out   too   track   

mapperLocations屬性萬用字元的使用

樣本:

[html] view plain copy print?
  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>

注意點:在classpath後面的*必不可少,缺少型號的話後面的萬用字元不起作用。

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

                *表示多個任一字元


               缺少classpath後面的*會報以下的錯誤:

[plain] view plain copy print?
  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.dao.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.$Proxy18.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.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)


[MyBatis]mapperLocations屬性萬用字元的使用

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.