JBoss: 包括模块路径中的子目录
JBoss: including subdirectories in Module Path
我正在使用 JBoss EAP 6.4
。我有一个模块文件夹,其中包含资源(我的应用程序所需的配置文件)并具有以下文件结构:
modules
|
|---resources
|
|---main
|
|---templates
| |---template1.xml
| |---template2.xml
|
|---axis2.xml
|---hibernate.cfg.xml
|---module.xml
我的 module.xml
文件如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="resources">
<resources>
<resource-root path="."/>
<resource-root path="./templates"/>
</resources>
</module>
我还有一个jboss-deployment-structure.xml
文件:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<deployment>
<dependencies>
<module name="resources" />
</dependencies>
</deployment>
</jboss-deployment-structure>
我将模块文件夹放在 JBOSS_MODULEPATH
中。应用程序可以在 modules/resources/main
中找到 XML 文件,例如 axis2.xml
和 hibernate.cfg.xml
。但是,它无法在子目录 templates
中找到文件,例如 template1.xml
.
有什么建议吗?
我找到了解决方法。启动 JBoss 服务器时,我使用以下启动参数:
-Dresource.path=/path/to/modules/resources/main
因此 resource.path
保留为环境 属性 我可以通过这种方式访问模板文件夹中的文件:
File f = new File(System.getProperty("resource.path") + "/templates/template1.xml");
我正在使用 JBoss EAP 6.4
。我有一个模块文件夹,其中包含资源(我的应用程序所需的配置文件)并具有以下文件结构:
modules
|
|---resources
|
|---main
|
|---templates
| |---template1.xml
| |---template2.xml
|
|---axis2.xml
|---hibernate.cfg.xml
|---module.xml
我的 module.xml
文件如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="resources">
<resources>
<resource-root path="."/>
<resource-root path="./templates"/>
</resources>
</module>
我还有一个jboss-deployment-structure.xml
文件:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<deployment>
<dependencies>
<module name="resources" />
</dependencies>
</deployment>
</jboss-deployment-structure>
我将模块文件夹放在 JBOSS_MODULEPATH
中。应用程序可以在 modules/resources/main
中找到 XML 文件,例如 axis2.xml
和 hibernate.cfg.xml
。但是,它无法在子目录 templates
中找到文件,例如 template1.xml
.
有什么建议吗?
我找到了解决方法。启动 JBoss 服务器时,我使用以下启动参数:
-Dresource.path=/path/to/modules/resources/main
因此 resource.path
保留为环境 属性 我可以通过这种方式访问模板文件夹中的文件:
File f = new File(System.getProperty("resource.path") + "/templates/template1.xml");