APP_URL=http://example.com DB_HOST=localhost DB_PORT=3306 <dependency> <groupId>io.github.cdimascio</groupId> <artifactId>dotenv-java</artifactId> <version>5.1.1</version> </dependency> APP_URL=http://example.com DB_HOST=localhost DB_PORT=3306 import io.github.cdimascio.dotenv.Dotenv; public class AppConfig { public static void main(String[] args) { String dbHost = dotenv.get("DB_HOST"); int dbPort = Integer.parseInt(dotenv.get("DB_PORT")); System.out.println("App URL: " + appUrl); System.out.println("DB Host: " + dbHost); System.out.println("DB Port: " + dbPort); } } App URL: http://example.com DB Host: localhost DB Port: 3306


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