1、@Value 获取信息 ,获取
xxx.yml
....
productCompares:
url: https://localhost:8080/manage/#/usercompare
...
xxxx.java
public class ProductInfo {
@Value("${productCompares.url}")
private String productCompares;
}
2、@ConfigurationProperties读取配置文件属性
a、pom.xml引入包
....
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
....
b、启动类需加入注解@EnableConfigurationProperties
c、xxx.yml配置
#小写 对应pfix
wechat:
corpId: asdfasdfasdf
toKen: 123123123
encodingAesKey: sdfasdfasvvxzUOj
customerContactSecret: AEMWm4ASDFASDF8352SWERFFDASDFmafHs
addressBookSecret: ASDFW23R2Fqwe2