注解
属性文件外置配置
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
amazon.accountId=pengganyu
- PropertyConfig信息,需要添加@ConfigurationProperties注解
package com.idcos.automate.config;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
@Component
@ConfigurationProperties(prefix = "amazon")
public class PropertyConfig {
private String accountId;
public String getAccountId() {
return accountId;
}
public void setAccountId(String accountId) {
this.accountId = accountId;
}
}