spring博大精深,衍生出了两大系列:spring boot 和sping cloud快速业务开发模式。
我们进行具体开发时,经常看到这样以Enable*开头的注解,如图
等等好多例子。。。框架自带的Enable*
看到不少网文吹嘘的上天了、神乎其威,我只说一句话:它(指Enable*)只是一种注解,可参考我的博文:
Spring中@Import的三种情况 https://www.cnblogs.com/dongguangming/p/12963060.html 和
Spring Bean注册的几种方式https://www.cnblogs.com/dongguangming/p/12792789.html
注册bean时的条件选择多,导致逻辑判断多
只要是在spring生态里搞开发,请务必搞清楚Spring Bean的生命周期过程和Bean的几种不同注册方式
根据各家公司的业务场景需求,也可以自己扩写Enable功能,如
在项目启动类上添加自定义注解:@EnablePrintService
可以把Enable*注解当成一个套路,实现方式其实是一样的,不管有多少个应用场景(@EnableScheduling、@EnableEurekaServer、@EnableDubbo、@EnablePrintService等等)。
既然是注解,那就
Spring Core Annotations:https://www.javacodegeeks.com/2019/05/spring-core-annotations.html
Spring Annotations [Quick Reference] https://javabeat.net/spring-annotations/
Spring才是核心,spring boot、spring cloud、第三方扩展都是Spring的衍生品!!!
重要的是说三遍: 抓住核心看本源!!!
参考:
0 . Annotation Type EnableAutoConfiguration
https://docs.spring.io/spring-boot/docs/current/api/org/springframework/boot/autoconfigure/EnableAutoConfiguration.html
1. Scheduling Tasks https://spring.io/guides/gs/scheduling-tasks/
2. Spring Job Scheduling with @Scheduled & @EnableScheduling Annotations http://websystique.com/spring/spring-job-scheduling-with-scheduled-enablescheduling-annotations/
3. @EnableScheduling in Spring https://stackoverflow.com/questions/41377002/enablescheduling-in-spring
4. Spring Annotations: Spring Cloud https://stackabuse.com/spring-annotations-spring-cloud/
5. Spring - BeanDefinitionRegistry https://anthony-dong.gitee.io/post/spring-beandefinitionregistry/
6. Grails - Java-Based Configuration
https://blog.andresteingress.com/2014/02/14/grails-java-based-spring-config.html
7. Spring Enable annotation – writing a custom Enable annotation
https://www.javacodegeeks.com/2015/04/spring-enable-annotation-writing-a-custom-enable-annotation.html
8. A Cron Expressions https://docs.oracle.com/cd/E12058_01/doc/doc.1014/e12030/cron_expressions.htm