编程语言
首页 > 编程语言> > java – 想法检查batis mapper bean错误

java – 想法检查batis mapper bean错误

作者:互联网

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 {

会做的

标签:java,intellij-idea,spring,mybatis,inspection
来源: https://codeday.me/bug/20190712/1437860.html