#端口,默认为8080
server.port=80
#访问路径,默认为/
server.context-path=/test
#输出日志文件,默认不输出
logging.file=/log.txt
#修改日志级别,默认为INFO
logging.level.root=DEBUG自定义properties文件
@PropertySource("classpath:config/xxx.properties")@PropertySource(value={"classpath:config/a.properties","classpath:config/b.properties"})key1=values1
key2=values2在JAVA代码中,使用@Value注解,在项目启动时会将自定义参数加载到全局变量,如下
@RestController
public class SampleController {
@Value(value="${key1}")
private String key;a.key1=values1
a.key2=values2@RestController
@ConfigurationProperties(prefix = "a")
public class SampleController {
private String key1;
private String key2;
public void setKey1(String key1) {
this.key1 = key1;
}
public void setKey2(String key2) {
this.key2 = key2;
}
768



被折叠的 条评论
为什么被折叠?



