Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Spring Boot中访问application.properties文件中定义的?_Spring_Spring Boot_Properties - Fatal编程技术网

如何在Spring Boot中访问application.properties文件中定义的?

如何在Spring Boot中访问application.properties文件中定义的?,spring,spring-boot,properties,Spring,Spring Boot,Properties,我想访问application.properties中提供的值,例如: logging.level.org.springframework.web: DEBUG logging.level.org.hibernate: ERROR logging.file=${HOME}/application.log userBucket.path=${HOME}/bucket 我想在Spring引导应用程序中访问主程序中的userBucket.path您可以使用@Value注释并访问您正在使用的任何Sp

我想访问application.properties中提供的值,例如:

logging.level.org.springframework.web: DEBUG
logging.level.org.hibernate: ERROR
logging.file=${HOME}/application.log

userBucket.path=${HOME}/bucket

我想在Spring引导应用程序中访问主程序中的userBucket.path

您可以使用@Value注释并访问您正在使用的任何Spring bean中的属性

@Value("${userBucket.path}")
private String userBucketPath;

您可以使用@Value注释并访问正在使用的任何Springbean中的属性

@Value("${userBucket.path}")
private String userBucketPath;