I have tried every option on web but not able to set the values in following method:
@Configuration @PropertySource("classpath:application.properties") public class MyDataSource { @Value("${db.driver}") private String DB_DRIVER; @Value("${db.url}") private String DB_URL; @Value("${db.username}") private String DB_USERNAME; @Value("${db.password}") private String DB_PASSWORD; @Bean public static PropertySourcesPlaceholderConfigurer placeHolderConfigurer() { return new PropertySourcesPlaceholderConfigurer(); } @Bean public DataSource getDataSource() { DriverManagerDataSource dataSource = new DriverManagerDataSource(); dataSource.setDriverClassName(DB_DRIVER); dataSource.setUrl(DB_URL); dataSource.setUsername(DB_USERNAME); dataSource.setPassword(DB_PASSWORD); return dataSource; } } My application.properties is in main/resources folder and values can be seen in variables in debug mode. But on running app, it shows Property ' ' must not be empty.
EDIT: I am not sure what can be the issue in first case? So changed the application.property file as suggested and code as below :
@Autowired protected JdbcTemplate jdbcTemp; public List<> getData(String id) { return jdbcTemp.query("SELECT ........,new RowMapper()); } But getting java.lang.NullPointerException: