1、解决方法
方法一:启动类上添加@ComponentScan注解将repository 层导入
方法二:在启动类中将获得repository包的bean(没用推广性,一次方法只返回一个repository对象)
方法三:写一个配置类,使用spring xml 配置方式,@ImportResource(locations = {"classpath:applicationContext.xml"})注解将xml中配置导入配置类
public class OwnApiApplication {
@Bean
public CustomerRepository getRepository() {
return new CustomerRepositoryImpl();
}
public static void main(String[] args) {
SpringApplication.run(OwnApiApplication.class, args);
}
}
1、加了@repository注解,api中启动类依然加载不到Repository,
原因:在启动类上使用MapperScan 注解扫描了repository 上级包导致