有一个带有Spring和MyBatis的网络项目。我在开发中使用了IntelliJ的思想。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>Mybati-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>有办法解决这个小问题吗?
发布于 2015-04-24 07:14:11
更新的MyBatis插件是固定的,没有这个问题。
发布于 2016-12-22 10:03:13
@Repository
@Mapper
public interface ApplicationMapper {会起作用的
发布于 2016-01-04 04:04:16
另一种方法是将@Component或@Repository添加到映射器接口中。
例如:
@Repository
public interface ApplicationMapper {
//...
}https://stackoverflow.com/questions/25379348
复制相似问题