有 Spring 和 MyBatis 的 Web 项目。我使用 IntelliJ IDEA 进行开发。 IDEA 无法正确检查 MyBatis bean 并产生烦人的下划线,尽管存在指向数据访问对象的链接。
检验意见:
Could not autowire. No beans of 'ApplicationMapper' type found.
我的 Spring 和 MyBatis 配置: Spring :
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="configLocation" value="classpath:spring/mybatis-config.xml"/>
</bean>
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.db.gbs.gbsapps.rds.backend.model.integration.mapping"/>
</bean>
mybatis-config.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<mappers>
<mapper resource="mybatis/ApplicationMapper.xml"/>
</mappers>
</configuration>
有办法解决这个小问题吗?
最佳答案
@Repository
@Mapper
public interface ApplicationMapper {
会成功的
关于java - idea检查batis mapper bean错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25379348/