Spring using PropertySource with @Value

If you are using @Value with @PropertySource create a PropertySourcesPlaceholderConfigurer Bean which resolves ${…} placeholders within @Value annotations against the current Spring Environment and its set of PropertySources.

public class DataSourceConfigImpl implements DataSourceConfig{
	private String devUserName;
	private String devPassword;
	private String devUrl;
	private String driverClass;
	public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
		return new PropertySourcesPlaceholderConfigurer();
    public DataSource devDataSource() {
		try {
			 BasicDataSource dataSource = new BasicDataSource();
			 return dataSource;
		} catch (Exception e) {
			logger.error("DataSourceConfigImpl.devDataSource(): " + e.getMessage());
		return null;


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s