mybatisエラー:Invalid bound statement:comp.prcsteel.peanut.dao.UserDao.selectById
5704 ワード
spring+mybatis配置Sql Session FactoryBen
2.UserDaoの方法はUserMapper.xmlにはありません.その後UserDaoを実行する方法はこれを報告します.
3、UserDaoの方法の戻り値はListであり、select要素はResultMapを正しく設定していないか、またはResultTypeのみを設定している!
4、上記の問題がないことを確認したら、該当するxmlファイルを任意に修正してください.例えば、空の行を削除して保存してください.問題の解決…
上記の問題はないと発見しました.ロゴをよく見ると、この出力があります.
理由:mapperファイルはresourceに置くのではなく、javaディレクトリ、mavenがコンパイルする時にxmlファイルをコンパイルしていません.解決:pomファイルにresourceを追加してコンパイルします.
<bean id="sqlSessionFactory" name="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="typeAliasesPackage" value="${mybatis.model}" />
<property name="mapperLocations" value="${mybatis.mapperLocations}" />
<property name="plugins">
<array>
<bean class="com.github.pagehelper.PageHelper">
<property name="properties" value="dialect=mysql"/>
bean>
array>
property>
bean>
プロキシインターフェースdaoはMapperScanConfigrerスキャンによって注入されます.
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.prcsteel.peanut.dao" />
bean>
ネット上のいくつかの提案を参照してください.1、
mapperファイルnamespaceとdaoパスは対応しています.2.UserDaoの方法はUserMapper.xmlにはありません.その後UserDaoを実行する方法はこれを報告します.
3、UserDaoの方法の戻り値はListであり、select要素はResultMapを正しく設定していないか、またはResultTypeのみを設定している!
4、上記の問題がないことを確認したら、該当するxmlファイルを任意に修正してください.例えば、空の行を削除して保存してください.問題の解決…
上記の問題はないと発見しました.ロゴをよく見ると、この出力があります.
[DEBUG] org.mybatis.spring.SqlSessionFactoryBean.buildSqlSessionFactory - Property 'mapperLocations' was not specified or no matching resources found
Sql Session FactoryBenは対応するmapper xmlファイルにロードされていません.もちろん、実行方法の場合はdao対応のmapperが見つからず、対応のsqlが実行できません.maven targetのclasesディレクトリの下にもmapperのxmlファイルが現れていません.理由:mapperファイルはresourceに置くのではなく、javaディレクトリ、mavenがコンパイルする時にxmlファイルをコンパイルしていません.解決:pomファイルにresourceを追加してコンパイルします.
<resources>
<resource>
<directory>src/main/javadirectory>
<includes>
<include>**/*include>
includes>
<filtering>falsefiltering>
resource>
resources>