Code: Select all
@PropertySource("file:/home/user/myapp/myapp.properties")
@SpringBootApplication
public class MyApplication {
public static void main(String... args) {
SpringApplication.run(MyApplication.class, args);
}
}
Code: Select all
@RestController
public class MyAppController {
@Value("${staticRepo}")
private String staticRepo;
@GetMapping(value = "/api/myapp")
List getFoo() {
if (staticRepo== null || staticRepo.trim().isEmpty()) {
throw new InternalServerErrorException("MyApp is not configured properlly. Missing 'staticRepo' parameter in 'myapp.properties'");
}
return FooUtils.load(staticRepo);
}
Ich habe mehrere Beiträge mit demselben Problem gefunden, aber keines löste mein Problem. Aus einem dieser Beiträge habe ich versucht, die Eigenschaftendatei wie folgt in die Befehlszeile anzugeben, aber ohne Glück ... < /p>
Code: Select all
java -jar /home/user/myapp/myapp.jar --spring.config.location=file:///home/user/myapp/myapp.properties