启动类加注解@MapperScan spring boot mybatis 启动错误

时间:2023-12-26 09:49:13

Description:

Field userDao in com.gcy.springsecuritydemo.service.user.UserService required a bean of type 'com.gcy.springsecuritydemo.dao.user.UserDao' that could not be found.

Action:

Consider defining a bean of type 'com.gcy.springsecuritydemo.dao.user.UserDao' in your configuration.

Disconnected from the target VM, address: '127.0.0.1:61935', transport: 'socket'

Process finished with exit code 1

解决办法:启动类加注解@MapperScan

@SpringBootApplication
@MapperScan("com.gcy.springsecuritydemo.dao")//mybatis扫描
public class SpringsecuritydemoApplication { public static void main(String[] args) {
SpringApplication.run(SpringsecuritydemoApplication.class, args);
}
}