springboot启动报错:Consider defining a bean of type 'com.xx.xx.TokenService' in your configuration.

原因:找不到请求的bean类型

1. 方法一:添加config注入bean

 

/**/
@Configuration
public class TokenConfig {
    /**
     *
     */
    @Bean
    public TokenService tokenService() {
        return new TokenService();
    }
}

2. 方法二:在启动类DemoApplication上添加包所在位置注解

@ComponentScan(value = {"com.bat.demo","com.bat.token.common"})

 

posted @ 2021-11-08 15:29  白玉神驹  阅读(1098)  评论(0)    收藏  举报