问题描述
我正在经历 JBoss.org 如何将外部文件放入类路径,但是不起作用.
I was going through JBoss.org how to put external file in the classpath, but it doesn't work.
我有1个文件名为"config.properties".它放置在jboss/modules/com/xsiraul/test/main/文件夹中.在同一文件夹中,有一个module.xml,它看起来像-
I have 1 file with name "config.properties". It is placed in jboss/modules/com/xsiraul/test/main/ folder. In the same folder there is module.xml which looks like -
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="com.xsiraul.test">
<resources>
<resource-root path="."/>
</resources>
</module>
我已经使用-
InputStream settingsStream = getClass().getClassLoader().getResourceAsStream("config.properties");
Java类位于名为com.xsiraul.test的程序包中
Java class is in package named com.xsiraul.test
问题在于方法getResourceAsStream
返回NULL,我不明白为什么.也许有人有什么主意吗?
The problem is that method getResourceAsStream
returns NULL and I don't understand why. Maybe somebody has any ideas?
我使用JBoss
EAP
6.1.0.GA版本.
I use JBoss
EAP
6.1.0.GA version.
推荐答案
您是否声明了对模块的依赖关系?也许你错过了..
Did you declare the dependency to your module? maybe you missed that..
将Dependencies: com.fico.test
添加到manifest.mf文件中
Add Dependencies: com.fico.test
to your manifest.mf file
这篇关于类路径中的JBoss外部属性文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!