<dependency> <groupId>io.github.cdimascio</groupId> <artifactId>dotenv-java</artifactId> <version>5.2.1</version> </dependency> DB_HOST=localhost DB_PORT=3306 DB_USERNAME=root DB_PASSWORD=pass123 import io.github.cdimascio.dotenv.Dotenv; public class MyLibrary { private static final Dotenv dotenv = Dotenv.configure().ignoreIfMissing().load(); public static String getDbHost() { return dotenv.get("DB_HOST"); } public static int getDbPort() { return Integer.parseInt(dotenv.get("DB_PORT")); } public static String getDbUsername() { return dotenv.get("DB_USERNAME"); } public static String getDbPassword() { return dotenv.get("DB_PASSWORD"); } }


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