spring boot多模块引用,bean注入问题:A component required a bean of type 'utils.JwtTokenUtil' that could not b

今天重构了下代码,模块拆分后,项目启动失败:

Description:

A component required a bean of type 'utils.JwtTokenUtil' that could not be found.


Action:

Consider defining a bean of type 'utils.JwtTokenUtil' in your configuration.

哦,显示的是没有引入到容器中的意思。

查看了代码:

spring boot多模块引用,bean注入问题:A component required a bean of type 'utils.JwtTokenUtil' that could not b_第1张图片

发现引入了啊,难道要用@Compent  ,哈哈肯定不是这样。

 

后面一看,我把找个工具类 utils.JwtTokenUtil放在mudel A中,而 启动类springApplication在mudel B中,

也就是springApplication在启动时候,没有把上面的utils包扫描进去进行构造,

解决: 

 @SpringBootApplication(scanBasePackages = {"utils"})


@SpringBootApplication(scanBasePackages = {"utils"})
@Configuration
@MapperScan("mybits.persistence")
public class SpringbootApplication {

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

}

可以了: 

你可能感兴趣的:(sbring,spring,cloud)