相关疑难解决方法(0)

Spring Boot @Value属性

我有一个Spring Boot应用程序,在其中一个类中,我尝试使用application.properties文件引用属性@Value.但是,该财产没有得到解决.我查看了类似的帖子,并尝试按照建议,但这没有帮助.这堂课是:

@Configuration
@ComponentScan
@EnableAutoConfiguration
public class PrintProperty {

  @Value("${file.directory}")
  private String fileDirectory;

  public void print() {
    System.out.println(fileDirectory);
  }
}
Run Code Online (Sandbox Code Playgroud)

我有属性file.directory application.properties.我也有其他领域.

spring spring-annotations spring-boot

30
推荐指数
4
解决办法
10万
查看次数

标签 统计

spring ×1

spring-annotations ×1

spring-boot ×1