property file looks like this:
url1=path_to_binary1
url2=path_to_binary2
According this I tried following approach:
@Component
@EnableConfigurationProperties
public class ApplicationProperties {
private Map<String, String> pathMapper;
//get and set
}
and in another component I autowired ApplicationProperties:
@Autowired
private ApplicationProperties properties;
//inside some method:
properties.getPathMapper().get(appName);
produces NullPointerException
.
How to correct it?
update
I have correct according user7757360 advice:
@Component
@EnableConfigurationProperties
@ConfigurationProperties(prefix="app")
public class ApplicationProperties {
and properties file:
app.url1=path_to_binary1
app.url2=path_to_binary2
Still doesn't work
Update 2
@Component
@EnableConfigurationProperties
@ConfigurationProperties(prefix="app")
public class ApplicationProperties {
private Map<String, String> app;
and inside application.properties
:
app.url1=path_to_binary1
app.url2=path_to_binary2
Still doesn't work