java -jar myapp.jar --port=8080 export DB_URL=jdbc:mysql://localhost:3306/mydb db.username=root db.password=secret import io.activej.config.Config; import io.activej.config.ConfigModule; public class MyApp { public static void main(String[] args) { Config config = Config.create() .withParser(ConfigModule.create() .withCommandLineArguments(args) .withEnvironmentVariables() .withPropertiesFile("myapp.properties") ) .withValue("db.username", "default_username") .withValue("db.password", "default_password") .build(); String dbUrl = config.get("db.url"); String dbUsername = config.get("db.username"); String dbPassword = config.get("db.password"); // ... } }


上一篇:
下一篇:
切换中文