1. 程式人生 > 其它 >js中常用的簡寫方式

js中常用的簡寫方式

@ConfigurationProperties使用

@ConfigurationProperties(

        prefix = "hello.properties"

)

public class MyProperties {


    private String myKey;

    private List<String> stringList;

    private Duration duration;


    public String getMyKey() {

        return myKey;

    }


    public
void 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 + '}'; } }
View Code

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

故鄉明