# announce your current env here in application.properties, and there must be different properties files in different env.(in the same relative path)
cur_env=DEV
LocalPropertyUtil.class
publicstatic String getProperty(String propertyName){
Properties p =newProperties();try{
Properties props = System.getProperties();
String homepath = props.getProperty("user.home");
FileInputStream fileInputStream = null;if(props.getProperty("os.name").toLowerCase().contains("windows")){
fileInputStream =newFileInputStream(newFile("..\\config\\application.properties"));}elseif(props.getProperty("os.name").toLowerCase().contains("mac")){// no}elseif(homepath.toLowerCase().contains("jenkins_home")){
fileInputStream =newFileInputStream(newFile("your ABS path of application.properties on jenkins "));}else{
fileInputStream =newFileInputStream(newFile("your ABS path of application.properties on other server"));}
p.load(fileInputStream);
fileInputStream.close();}catch(IOException e1){
logger.error("Exception", e1);}return p.getProperty(propertyName);}
Service.Class
# if you must use a mock data in your dev environment, and it will be real data in production environment, you can do it like this.
Model model =newModel();if(LocalPropertyUtil.getProperty("cur_env").equalsIgnoreCase(ConstantDefine.ENV.PROD)){
model =getRealData();}else{
model.setId("762980");}