Spring和mybatis整合時報出的錯誤
阿新 • • 發佈:2019-02-17
錯誤:
Caused by: org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'org.apache.ibatis.session.defaults.DefaultSqlSessionFactory' to required type 'java.lang.String' for property 'sqlSessionFactoryBeanName'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [org.apache.ibatis.session.defaults.DefaultSqlSessionFactory] to required type [java.lang.String] for property 'sqlSessionFactoryBeanName': no matching editors or conversion strategy found
出現錯誤的原因:
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<!-- 會話工廠 -->
<property name="sqlSessionFactoryBeanName"
value="sqlSessionFactoryBean"/>
上面property中value修改為了ref,就會報出錯誤,正確的寫法應該是使用value屬性