I am trying to read a simple config.properties file but i keep getting null as the value.
I have config.properties file under the root (at the same level with pom.xml) I have only one line in config.properties.
KEY=baran
And i have an AppConfig class like below
package tr.com.simroll.ada.rvm.web.config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
@Configuration
@PropertySource("classpath:config.properties")
public class AppConfig {
@Value("${KEY}")
private String test;
public String getTest() {
return test;
}
public void setTest(String test) {
this.test = test;
}
}
I am trying to access from my controller like this
@Controller
@CrossOrigin(origins = "*")
public class MovieCategoryController {
@RequestMapping(value = "/api/movieCategory/list", method = RequestMethod.GET)
@ResponseBody
public String listMovieCategories(ModelMap model, HttpServletResponse res, HttpServletRequest req) {
AppConfig config = new AppConfig();
System.out.println(config.getTest());
return "test";
}