org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.threegrand.urdm.system.dao.UserDao.saveUser
Scheme 1 Scheme 2 Scheme 3 I mainly get inspiration from the latter two schemes. First, look at my configuration. I use the @Repository annotation of mybatis to inject the mybatis interface:
<!-- MyBatis配置 -->
<bean id="sqlSessionFactory1" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="configLocation" value="classpath:/mybatis/configuration-mybatis.xml"/>
<!-- 显式指定Mapper文件位置 -->
<property name="mapperLocations">
<list>
<value>classpath*:/mapper/UserDao.xml</value>
</list>
</property>
<property name="configurationProperties">
<props>
<!-- mapUnderscoreToCamelCase属性将表中列名的下划线映射为JavaBean属性的驼峰式命名,默认为false -->
<prop key="mapUnderscoreToCamelCase">true</prop>
</props>
</property>
</bean>
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
I have used mybatis plugins to check all potential errors, of course, the startup log, rewrite the project, and check every configuration that may be wrong, but it still doesn't work. I put the xml file and the Dao interface under a package name, and then let the annotation scan and perform dynamic proxying, but I still can't find the problem. I still can't use the debug mode to simulate the method call. I heard that the xml file should be put into the mappers in config-mybatis.xml, but it is still not easy to use. I have tried it in the code resource file and the test resource file under the idea. , I discussed it with another friend, but to no avail.
Later, put the mapper mapping file in the resource directory, and the scan turned out to be easy.
As shown in the figure: