I'm trying to use a PropertyReader class to get my information (portNumber, hostName, etc) from a test.properties file in java spring, but I am pretty confused on how to go about this because there seems to be a million different ways (resource bundle etc)... I would greatly appreciate any input! Here's what my code looks like. Oh and the names are the same as in the properties file.
@Configuration @PropertySource("classpath:test.properties") public class PropertyReader { private Environment environment; String portNumber; String hostName; String subjectName; String myUrl; String portProtocol; String hostProtocol; @Bean public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() { return new PropertySourcesPlaceholderConfigurer(); } public PropertyReader(String propertyFile) throws IOException {...} I've already added
<context:property-placeholder location="classpath:test.properties" /> to my context. but not sure how to go about getting the info as environment.getProperty doesn't seem to be recognized as a function...