Created
November 11, 2016 17:43
-
-
Save unamanic/a7eb0c17b78fb03617cc955b06285b1d to your computer and use it in GitHub Desktop.
Setting system properties from config server (or application.properties)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.boot.CommandLineRunner; | |
import org.springframework.boot.SpringApplication; | |
import org.springframework.boot.autoconfigure.SpringBootApplication; | |
import org.springframework.core.env.Environment; | |
@SpringBootApplication | |
public class SystemPropertiesApplication implements CommandLineRunner{ | |
public static void main(String[] args) { | |
SpringApplication.run(SystemPropertiesApplication.class, args); | |
} | |
private final Environment env; | |
@Autowired | |
public SystemPropertiesApplication(Environment env) { | |
this.env = env; | |
} | |
@Override | |
public void run(String... strings) throws Exception { | |
if(env.containsProperty("system.javax.net.ssl.keyStore")) { | |
String keystore = env.getProperty("system.javax.net.ssl.keyStore"); | |
System.out.println(keystore); | |
System.getProperties().setProperty("javax.net.ssl.keyStore", keystore); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment