js中常用的簡寫方式
阿新 • • 發佈:2021-08-13
@ConfigurationProperties使用
@ConfigurationProperties( prefix = "hello.properties" ) public class MyProperties { private String myKey; private List<String> stringList; private Duration duration; public String getMyKey() { return myKey; } publicView Codevoid setMyKey(String myKey) { this.myKey = myKey; } public List<String> getStringList() { return stringList; } public void setStringList(List<String> stringList) { this.stringList = stringList; } public Duration getDuration() {return duration; } public void setDuration(Duration duration) { this.duration = duration; } @Override public String toString() { return "MyProperties{" + "myKey='" + myKey + '\'' + ", stringList=" + stringList + ", duration=" + duration + '}'; } }
prefix
屬性是配置檔案裡的字首,即配置檔案中以字首 + 變數名
的形式配置一條記錄,來對應類中的一個變數,如下:
hello.properties.myKey=hello hello.properties.duration=20s hello.properties.string-list[0]=Acelin hello.properties.string-list[1]=nice
@ConfigurationProperties特點
hello.properties.myKey=hello hello.properties.mykey=hello hello.properties.my-key=hello hello.properties.my_key=hello hello.properties.MY_KEY=hello hello.properties.MY-KEY=hello
https://www.cnblogs.com/acelin/p/15167266.html
故鄉明