{ database: { url: "jdbc:mysql://localhost:3306/mydb", username: "admin", password: "admin123" }, logging: { level: "debug", enabled: true } } import com.typesafe.config.Config; import com.typesafe.config.ConfigFactory; public class MyApp { public static void main(String[] args) { Config config = ConfigFactory.load("config.conf"); String dbUrl = config.getString("database.url"); String dbUsername = config.getString("database.username"); String dbPassword = config.getString("database.password"); boolean loggingEnabled = config.getBoolean("logging.enabled"); String logLevel = config.getString("logging.level"); System.out.println("Database URL: " + dbUrl); System.out.println("Database Username: " + dbUsername); System.out.println("Database Password: " + dbPassword); System.out.println("Logging Enabled: " + loggingEnabled); System.out.println("Logging Level: " + logLevel); } }


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