spring注解

 

@SpringBootApplication

 


 实质上包含了三个注解,由于@SpringBootAplication包含了@ComponentScan,所以就自动开启了组件扫描,默认的扫描范围应该是它父目录下的所有目录。

 

 

@RestTemplate

use RestTemplate ,you can comsume Restful web service

使用RestTemplate,可以访问Restful web服务,即可以发送网络请求。

 

 这是RestTemplate最基本的用法,无参数请求,返回一个Quote对象

 

 有很多方法,传什么参数,返回什么类型的数据都能看出来,其他的怎么用还不知道。

我在自己写测试案例的时候,是自己创建的RestTemplate对象,这显然是不符合IOC的。

 

 这是官方的方法,应该是使用了工厂代理模式,调用方法来生成RestTemplate对象。

 @JsonIgnoreProperties

 不甚理解,这两个方法,都没有被调用过,却都执行了。没调用过,参数是怎么传进去的呢?

 

 indicate that any properties not bound in this type should be ignored.

 

 

 @JsonProperty

把属性值多的对象,赋给属性值少的对象会怎么样呢?


 

 @Scheduled(fixedRate = 5000)

 

 

<dependency>
  <groupId>org.awaitility</groupId>
  <artifactId>awaitility</artifactId>
  <version>3.1.2</version>
  <scope>test</scope>
</dependency>

@Scheduled注解各参数详解 - 简书 (jianshu.com)


 

posted @ 2021-09-03 12:39  北征愚人  阅读(37)  评论(0编辑  收藏  举报