摘要: Spring定时任务 1、@Scheduled注解方式 使用方式 @Scheduled的使用方式十分简单,首先在项目启动类添加注解@EnableScheduled。 编写定时任务方法,方法上添加注解@Scheduled。 如果有多个定时任务,可以使用异步或者多线程解决。 参数说明 @Schedule 阅读全文
posted @ 2022-09-21 15:17 盗梦笔记 阅读(1150) 评论(0) 推荐(0) 编辑
摘要: Spring常见的DI方式 字段注入(Field Injection) 在字段上使用@Autowired/Resource注解 字段注入是日常开发中使用最多的一种注入方式,它的实现代码如下: @Autowired private UserService userService; 优点 属性注入最大的 阅读全文
posted @ 2022-09-21 10:25 盗梦笔记 阅读(258) 评论(0) 推荐(0) 编辑
摘要: Java调用第三方http接口的方式 通过JDK网络类Java.net.HttpURLConnection; 通过common封装好的HttpClient; 通过Apache封装好的CloseableHttpClient; 通过SpringBoot-RestTemplate; 通过okhttp 通过 阅读全文
posted @ 2022-09-21 09:06 盗梦笔记 阅读(460) 评论(0) 推荐(0) 编辑