我的@SpringBootApplication注释存在于com.abc.def
包中。
根据这篇文章,使用 @SpringBootApplication 注解相当于使用 @Configuration、@EnableAutoConfiguration 和 @ComponentScan 及其默认属性:-
如果我提供自己的@ComponentScan
,它是否会将新包添加到默认值或完全覆盖默认值?
最佳答案
@SpringBootApplication注解可以组件从Application类所属的包中扫描类。您还可以添加@ComponentScan来扫描不在Application类所属包下的类。
@ComponentScan("external.pkg")
@SpringBootApplication
class MyApp{
}
关于spring-boot - @ComponentScan是否覆盖@SpringBootApplication?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65540306/