springboot使用JPA数据访问启动报错consider defining a bean of type ‘..**Repository’ in your configuration.

maven工程: SpringBoot1.5 +Web+JPA+MYSQL+JDBC

报错信息

***************************
APPLICATION FAILED TO START
***************************

Description:

Field userRepository in com.lvshuy.addresslist.controller.UserController required a bean of type 'com.lvshuy.addresslist.repository.UserRepository' that could not be found.


Action:

Consider defining a bean of type 'com.lvshuy.addresslist.repository.UserRepository' in your configuration.

解决办法:
在启动类加上@ComponentScan注解。

@ComponentScan(basePackages = {"com.lvshuy.addresslist.repository"})
public class AddresslistApplication {

    public static void main(String[] args) {
        SpringApplication.run(AddresslistApplication.class, args);
    }
}

相关问题:
【SpringBoot 启动报错Cannot determine embedded database driver class for database type NONE】

更多推荐

springboot使用jpa启动报错consider defining a bean of type '*.*.**Repository'