Maven 工程读取配置文件路径

在Maven工程中会常常碰到 读取配置文件(配置文件存放在resource目录下)xml

  1. public static void main(String[] args) throws ParserConfigurationException, Exception{  
  2.         ClassLoader classLoader = TestDom.class.getClassLoader();  
  3.         URL resource = classLoader.getResource("test.xml");  
  4.         String path = resource.getPath();  
  5.         System.out.println(path);  
  6. }
相关文章
相关标签/搜索