有Spring和MyBatis的网络项目.我使用IntelliJ IDEA进行开发.
虽然存在与数据访问对象的链接,但IDEA无法正确检查MyBatis bean并产生令人讨厌的欠压.
检查评论:
Could not autowire. No beans of 'ApplicationMapper' type found.
我的Spring和MyBatis配置:
弹簧:
<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 {
会做的