springboot中注解作用

1.@SpringBootApplication: 等价于同时使用@Configuration @EnableAutoConfiguration @ComponentScan

spring boot中使用@SpringBootApplication指定类为应用启动类,

自动扫描于当前类同级以及子包下的相应注解注册为spring beans,

在类中main方法中通过SpringApplication的run方法启动应用。

详情参考:https://blog.youkuaiyun.com/yhl_jxy/article/details/72599063

2.@ServletComponentScan

在 SpringBootApplication 上使用@ServletComponentScan 注解后,Servlet、Filter、Listener 可以直接通过 @WebServlet、@WebFilter、@WebListener 注解自动注册,无需其他代码

详情参考:https://blog.youkuaiyun.com/catoop/article/details/50501686

3.@EnableScheduling

定时任务在配置类上添加@EnableScheduling开启对定时任务的支持,在相应的方法上添加@Scheduled声明需要执行的定时任务。 

详情参考:https://blog.youkuaiyun.com/u014231523/article/details/76263304?locationNum=7&fps=1

4.@EnableTransactionManagement

使用注解 @EnableTransactionManagement 开启事务支持后,然后在访问数据库的Service方法上添加注解 @Transactional 便可。

5.@EnableFeignClients

当前service服务要调用到其他service服务的api接口时,可通过EnableFeignClients调用其他服务的api

详情参考:https://www.cnblogs.com/UniqueColor/p/7130782.html

6.@EnableDiscoveryClient

把服务注册到Eureka Server

详情参考:https://my.oschina.net/eacdy/blog/1609308

7.@MapperScan

通过使用@MapperScan可以指定要扫描的Mapper类的包的路径

详情参考:https://blog.youkuaiyun.com/u013059432/article/details/80239075

8.@ComponentScan

定义扫描的路径从中找出标识了需要装配的类自动装配到spring的bean容器中

详情参考:http://blog.51cto.com/4247649/2118342

9.@EnableAutoConfiguration

@EnableAutoConfiguration可以帮助SpringBoot应用将所有符合条件的@Configuration配置都加载到当前SpringBoot创建并使用的IoC容器

详情参考:https://blog.youkuaiyun.com/zxc123e/article/details/80222967

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值