From a688cdd3ec0d81fb71d39d11b028d9bf95e68a07 Mon Sep 17 00:00:00 2001 From: Pekka Helenius Date: Wed, 21 Oct 2020 17:04:40 +0300 Subject: [PATCH] Replace getFile() with getInputStream(), required by WAR deployment Signed-off-by: Pekka Helenius --- .../bookstore/config/AdditionalPropertiesConfig.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bookstore/src/main/java/com/fjordtek/bookstore/config/AdditionalPropertiesConfig.java b/bookstore/src/main/java/com/fjordtek/bookstore/config/AdditionalPropertiesConfig.java index 9e780e3..7075f29 100644 --- a/bookstore/src/main/java/com/fjordtek/bookstore/config/AdditionalPropertiesConfig.java +++ b/bookstore/src/main/java/com/fjordtek/bookstore/config/AdditionalPropertiesConfig.java @@ -69,7 +69,14 @@ public class AdditionalPropertiesConfig implements EnvironmentPostProcessor { for (String prefix : resourceFilePrefixes) { try { ClassPathResource classPathResource = new ClassPathResource(prefix + "-" + profile + ".properties"); - classPathResource.getFile().canRead(); + + /* + * Do not use getFile() method. + * Instead, use getInputStream(), required by Tomcat/WAR deployment + */ + + classPathResource.getInputStream(); + classPathResources.add(classPathResource); System.out.printf( "Profile properties file found: %s\n",