141742327.png


public class ReadProtertise {

private static final String PROPERTIES_FILE="/com/config/db_config.properties";

public static void main(String[] args) {

getProperties();

}

public static void getProperties() {

InputStream in = DataSource.class.getResourceAsStream(PROPERTIES_FILE);

Properties pp = new Properties();

try {

pp.load(in);

System.out.println(pp.getProperty("driverClass"));

System.out.println(pp.getProperty("jdbcUrl"));

} catch (IOException e) {

e.printStackTrace();

}

}

}

//读取配置文件,后期维护方便