[英]how does @SpringBootApplication actually work in spring boot?
I don't understand how the SpringBootApplication shortcut works. 我不明白SpringBootApplication快捷方式是如何工作的。 Specifically I don't understand how the individual sub annotations like @ComponentScan and @EnableAutoConfiguration get passed onto the actual application class as if they were written explicitly there.
具体来说,我不明白像@ComponentScan和@EnableAutoConfiguration这样的单个子注释如何传递到实际的应用程序类,就好像它们是在那里明确写出的一样。 I searched spring boot's code base for SpringBootApplication expecting to see code that looks for the "SpringBootApplication" string before applying these individual annotations but did not see any.
我搜索Spring Boot的SpringBootApplication代码库,期望在应用这些单独的注释之前看到代码查找“SpringBootApplication”字符串,但没有看到任何代码。 Can someone explain this?
有人可以解释一下吗? Thanks.
谢谢。
The @SpringBootApplication
annotation is an annotation that is annotated with, among others, the annotations @ComponentScan
and @EnableAutoConfiguration
you mentioned. @SpringBootApplication
注释是一个注释,其中注释了您提到的注释@ComponentScan
和@EnableAutoConfiguration
。 Instead of scanning for @SpringBootApplication
, Spring internally scans for these (implicit) annotations and does its magic accordingly. Spring不会扫描
@SpringBootApplication
,而是在内部扫描这些(隐式)注释并相应地@SpringBootApplication
其魔力。
http://www.journaldev.com/7989/key-components-and-internals-of-spring-boot-framework http://www.journaldev.com/7989/key-components-and-internals-of-spring-boot-framework
And also Spring Boot reduces defining of Annotation configuration. 而且Spring Boot还减少了Annotation配置的定义。 If we use @SpringBootApplication annotation at class level, then Spring Boot AutoConfigurator will automatically add all required annotations to Java Class ByteCode.
如果我们在类级别使用@SpringBootApplication批注,那么Spring Boot AutoConfigurator会自动将所有必需的批注添加到Java Class ByteCode。
==> actually i can't find the code in spring boot autoconfig that does this. ==>实际上我找不到执行此操作的spring boot autoconfig中的代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.