Home > Software design >  Using System path in Spring Boot application.properties
Using System path in Spring Boot application.properties

Time:05-11

In the actual production and development servers, the base path is set with the code below.

private static String FILE_DIR = System.getProperty("user.dir")   File.separator   "FILES";

I want to move this code to application.properties.

Is there a way to use a path like System.getProperty in application.properties?

Sorry for such a novice question

CodePudding user response:

I tried the following in application.yml and it worked.

filedir: ${user.dir}${file.separator=='\\' ?/:\\}FILES

And then

@Value("${filedir}")
private String fileDir;

Please let me know it it wrks for you.

  • Related