Unable to load xml file from a absolute path

后端 未结 2 1208
-上瘾入骨i
-上瘾入骨i 2020-12-22 02:04

There is a maven project A. Once I do mvn clean install, the project builds and the jar is available at my local repository ie c:\\repository\\com\\stackoverflow\\A\\A.jar<

2条回答
  •  心在旅途
    2020-12-22 02:49

    I think you're asking the wrong question. You probably want to know has to access p.xml. The best way is to put A.jar on the classpath, which you do by specifying it as a dependency in the pom.xml of "the other Maven Project". In your code you do the following:

    Foo.class.getResource("/thePackagePath/to/p.xml");
    

    By trying to access the xml as a file, you make your project very bad portable to other systems.

提交回复
热议问题