0

I configure it like this in the application-context.xml

<mybatis:scan base-package="com.db"/>

And add @Component for the mapper interface.

@Component
public interface MenuMapper {}

And autowire it like this.

@Autowired
MenuMapper menuMapper;

It generates errors in IDEA. The error is

No beans of type MenuMapper found.

Kirby
  • 15,127
  • 10
  • 89
  • 104
Angle Tom
  • 1,060
  • 1
  • 11
  • 29

2 Answers2

1

Add @Repository to your MenuMapper interface

CaptRespect
  • 1,985
  • 1
  • 16
  • 24
0

This because mybatis set bean definition class as MapperFactoryBean, so it's not able to find type of mapper. You can use @Resource replace @Autowired. See ClassPathMapperScanner for detail.

lover summer
  • 43
  • 1
  • 7