DB_URL=jdbc:mysql://localhost:3306/mydatabase DB_USERNAME=root DB_PASSWORD=secret API_KEY=1234567890 import io.github.cdimascio.dotenv.Dotenv; public class Main { public static void main(String[] args) { String dbUrl = dotenv.get("DB_URL"); String dbUsername = dotenv.get("DB_USERNAME"); String dbPassword = dotenv.get("DB_PASSWORD"); String apiKey = dotenv.get("API_KEY"); // ... } } Dotenv dotenv = Dotenv.configure().directory("/path/to/config").load();


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