Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Read configurations from application.properties file
package edu.gatech.epidemics;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;
/**
* @author atalati
*/
@Component
@PropertySource("application-${spring.profiles.active}.properties")
@ConfigurationProperties
public class AppConfigBean {
@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;
@Value("${db_platform}")
private String db_platform;
// getters and setters ...
// toString() override
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment