在Maven工程中會常常碰到 讀取配置文件(配置文件存放在resource目錄下)xml
- public static void main(String[] args) throws ParserConfigurationException, Exception{
- ClassLoader classLoader = TestDom.class.getClassLoader();
- URL resource = classLoader.getResource("test.xml");
- String path = resource.getPath();
- System.out.println(path);
- }