application.properties配置变量 java

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
 
public class MyComponent {
 
    @Value("${my.property}")
    private String myProperty;
 
    public String getMyProperty() {
        return myProperty;
    }
}
#在application.properties文件中,你可以定义my.property:


my.property=Hello, World!

 

posted @ 2024-09-22 12:05  刘贵庆  阅读(64)  评论(0)    收藏  举报