使用@ComponentScan注释扫描多个包

当使用@ComponentScan来进行包扫描时
当只扫描一个包可写为

@ComponentScan("包名")
例如:@ComponentScan("com.example.service.rpc")

当扫描的包是多个时,应当使用数组的形式

例如:@ComponentScan({"com.example.service.rpc","com.example.web.controller"})
发布了54 篇原创文章 · 获赞 13 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/liutaiyi8/article/details/98989696