读取properties文件

    xiaoxiao2021-12-15  42

    private static String driver; private static String url; private static String username; private static String password; private static int batchno; //初始化,綁定properties中的jdbc屬性值 static { Properties prop = new Properties(); InputStream in = jdbcUtil.class.getResourceAsStream("/application.properties"); try { prop.load(in); driver = prop.getProperty("spring.datasource.driver-class-name").trim(); url = prop.getProperty("spring.datasource.url").trim(); username = prop.getProperty("spring.datasource.username").trim(); password = prop.getProperty("spring.datasource.password").trim(); batchno = Integer.parseInt(prop.getProperty("spring.datasource.batchno").trim()); } catch (IOException e) { e.printStackTrace(); } }
    转载请注明原文地址: https://ju.6miu.com/read-1000112.html

    最新回复(0)