java - idea检查batis mapper bean错误

标签 java spring intellij-idea mybatis inspection

有 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/

相关文章:

java - Spring JPA 创建具有空值的实体

java - 从没有主类的代码创建 JAR

spring-boot - IntelliJ Gradle 构建失败 : Incompatible because component compatible with Java 17 and the consumer needed Java 11

java - eclipse,动态Web项目,将另一个eclipse项目添加到类路径

java - Spring Data - 从表中获取最后一条记录

java - OSGi:BND 工具无法仅 @Reference 特定组件

java - 如果连接已关闭,Spring 客户端需要从池中检索连接

java - JPA/Hibernate:在复杂类上使用AttributeConverter时创建UserType是否明显?

java - @Autowired 无法在测试类中注入(inject) bean

java - Genymotion 初始化引擎 : failed in IntelliJ