I have two messages.properties files. One is located inside resources and another one is outside my .jar file in a directory called etc.
This is my PropertiesConfiguration class:
@Configuration
public class PropertiesConfiguration {
@Bean
public PropertyPlaceholderConfigurer properties() {
final PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
ppc.setIgnoreResourceNotFound(true);
final List<Resource> resourceLst = new ArrayList<Resource>();
resourceLst.add(new FileSystemResource("etc/application.properties"));
resourceLst.add(new FileSystemResource("etc/messages.properties"));
resourceLst.add(new FileSystemResource("etc/messages_et.properties"));
ppc.setLocations(resourceLst.toArray(new Resource[]{}));
return ppc;
}
}
In the logs I see this:
11:18:43.764 INFO [main] PropertyPlaceholderConfigurer - Loading properties file from file [C:\Users\deniss\IdeaProjects\repgen\etc\application.properties]
11:18:43.764 WARN [main] PropertyPlaceholderConfigurer - Could not load properties from file [C:\Users\deniss\IdeaProjects\repgen\etc\application.properties]: etc\application.properties (The system cannot find the file specified)
11:18:43.764 INFO [main] PropertyPlaceholderConfigurer - Loading properties file from file [C:\Users\deniss\IdeaProjects\repgen\etc\messages.properties]
11:18:43.764 INFO [main] PropertyPlaceholderConfigurer - Loading properties file from file [C:\Users\deniss\IdeaProjects\repgen\etc\messages_et.properties]
As I understand my messages.properties from etc is loaded. Although when the application is working, the values from it are not used. They are coming from default messages.properties inside my resources project folder. Am I doing something wrong?