Skip to content

Instantly share code, notes, and snippets.

@aarshtalati
Last active March 27, 2018 12:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aarshtalati/ae386471c78e815d4fed3b801557923c to your computer and use it in GitHub Desktop.
Save aarshtalati/ae386471c78e815d4fed3b801557923c to your computer and use it in GitHub Desktop.
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