Web services 访问aar文件中的属性文件

Web services 访问aar文件中的属性文件,web-services,properties,axis2,Web Services,Properties,Axis2,我已经创建了一个属性文件,正在通过我的代码访问该属性文件,如下所示: java.util.Properties clientProperties = new java.util.Properties(); try{ System.out.println("reading properties file"); clientProperties.load(new FileInputStream("Get_Remove.propertie

我已经创建了一个属性文件,正在通过我的代码访问该属性文件,如下所示:

java.util.Properties clientProperties = new java.util.Properties();
        try{
            System.out.println("reading properties file");
            clientProperties.load(new FileInputStream("Get_Remove.properties"));
            String CONF_FILE_EHCACHE_XML = clientProperties.get("CONF_FILE_EHCACHE_XML").toString();
            System.out.println("ehcache_Address : " + CONF_FILE_EHCACHE_XML);
        }catch(IOException ioe){
            System.out.println("Property file read exception: ");
            ioe.printStackTrace();
        }
现在,我已经将包含上述代码的项目部署为axis2中的AAR文件。但当我启动axis2服务器并点击上述服务,然后在读取属性文件时,它在axis2控制台抛出异常,如下所示:

Property file read exception:
java.io.FileNotFoundException: Get_Remove.properties (The system cannot f
ind the path specified)
那么,如何从部署在axis2中的服务以.aar文件的形式访问.property文件呢。
期待你的回答。提前感谢

当您从Java代码访问文件时,必须考虑路径。有许多方法可以获取文件的路径

我猜您的属性文件位于AAR文件的根目录下

请尝试以下代码:

clientProperties.load(this.getClass().getClassLoader().getResourceAsStream(“Get_Remove.properties”)

我希望这有帮助

谢谢