[MyBatis]mapperLocations属性ワイルドカードの使用
1808 ワード
http://blog.csdn.net/szwangdf/article/details/23432783
例:
classipathの後ろにある*は欠かせません。型番がないと後のワイルドカードが機能しません。
**表示は、任意のマルチレベルディレクトリを表しても良いです。例えば、上記の構成は【com/huaxin/frame ew/system/dao/UserDaoMapper.xml】を確認できます。
*複数の任意文字を表します。
classipathの後ろの*会報以下のエラーがあります。
org.mybatis.spring.MyBatis System Exception:neted exception is org.apache.ibatis.exceptions.Persistence Exception: ### Error querying database. Cause:java.lang.Illegel Argement Exception:Mapped Sttemens collection does not contain value for frame ew.system.dao.UserDao.get Next UserId_MySQL ### Cause:java.lang.Illegel Argement Exception:Mapped Sttemens collection does not contain value for frame ew.system.dao.UserDao.get Next UserId_MySQL at org.mybatis.spring.MyBatis Exception Translate.tranlateException IfPossible(MyBatis Exception Translate.java:75) at org.mybatis.spring.Sql Session Template$Sql Session Interceptor.invoke(Sql Session Template.java:371) at comp.sun.proxy.$Proxy 18 selectOne(Unknown Source) at org.mybatis.spring.Sql Session Template.selectOne(Sql Session Template.java:163) at comp.huaxin.fram ework.co re.dao.impl.BasedaoImpl.selectOne(BaseDaoImpl.java:298) at comp.huaxin.fram ew.system.dao.impl.UserDaoImpl.get Next UserId(UserDampl.java:41)
例:
<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>
注意点:classipathの後ろにある*は欠かせません。型番がないと後のワイルドカードが機能しません。
**表示は、任意のマルチレベルディレクトリを表しても良いです。例えば、上記の構成は【com/huaxin/frame ew/system/dao/UserDaoMapper.xml】を確認できます。
*複数の任意文字を表します。
classipathの後ろの*会報以下のエラーがあります。
org.mybatis.spring.MyBatis System Exception:neted exception is org.apache.ibatis.exceptions.Persistence Exception: ### Error querying database. Cause:java.lang.Illegel Argement Exception:Mapped Sttemens collection does not contain value for frame ew.system.dao.UserDao.get Next UserId_MySQL ### Cause:java.lang.Illegel Argement Exception:Mapped Sttemens collection does not contain value for frame ew.system.dao.UserDao.get Next UserId_MySQL at org.mybatis.spring.MyBatis Exception Translate.tranlateException IfPossible(MyBatis Exception Translate.java:75) at org.mybatis.spring.Sql Session Template$Sql Session Interceptor.invoke(Sql Session Template.java:371) at comp.sun.proxy.$Proxy 18 selectOne(Unknown Source) at org.mybatis.spring.Sql Session Template.selectOne(Sql Session Template.java:163) at comp.huaxin.fram ework.co re.dao.impl.BasedaoImpl.selectOne(BaseDaoImpl.java:298) at comp.huaxin.fram ew.system.dao.impl.UserDaoImpl.get Next UserId(UserDampl.java:41)