import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.CachingConfigurerSupport;
import org.springframework.stereotype.Component;
@SpringBootApplication
@Component
public class AttributeApplication extends CachingConfigurerSupport{
private static final String SPRING_ORGID_ARRAY = "spring.orgid.array";
private static final String SPRING_ROLES_ARRAY = "spring.roles.array";
//private static final String SPRING_ROLES_LIST = "spring.roles.list";
private static final String SPRING_SMS_TIMER = "spring.sms.timer";
private static final String SPRING_ARTICLETYPE_ID = "spring.articletype.id";
private static final String SPRING_KEYWORD_URL = "spring.keyword.url";
@Value("${"+SPRING_KEYWORD_URL+"}")
private String keywordUrl;
@Value("${"+SPRING_ARTICLETYPE_ID+"}")
private int articleTypeId;
@Value("${"+SPRING_SMS_TIMER+"}")
private int smsTimer;
@Value("${" + SPRING_ORGID_ARRAY + "}")
private int[] orgIdArray;
// @Value("#{'${" + SPRING_ROLES_LIST + "}'.split(',')}")
// private List<Integer> roleList;
@Value("${" + SPRING_ROLES_ARRAY + "}")
private int[] roleArray;
// public List<Integer> getRoleList() {
// return roleList;
// }
public int[] getRoleArray() {
return roleArray;
}
public int[] getOrgIdArray() {
return orgIdArray;
}
/** 短信有效时长 **/
public int getSmsTimer() {
return smsTimer;
}
public int getArticleTypeId() {
return articleTypeId;
}
public String getKeywordUrl() {
return keywordUrl;
}
/* public static void main(String[] args) {
ConfigurableApplicationContext applicationContext = SpringApplication.run(AttributeApplication.class, args);
AttributeApplication bean = applicationContext.getBean(AttributeApplication.class);
// bean.getRoleList();
bean.getRoleArray();
}*/
}
//======application.properties
#多个,转数组
spring.roles.array=73,74,40
#单个
spring.sms.timer=5