【问题标题】:How to reference a websphere Resource Environment Provider in web.xml?如何在 web.xml 中引用 websphere 资源环境提供者?
【发布时间】:2014-11-08 11:38:50
【问题描述】:
【问题讨论】:
标签:
java
xml
websphere
web.xml
【解决方案1】:
您可以手动将其添加到web.xml和ibm-web-bnd.xml中(此示例对应您提到的DW文章,请相应更改):
web.xml
<resource-env-ref>
<description />
<resource-env-ref-name>MyConstants</resource-env-ref-name>
<resource-env-ref-type>com.ibm.acme.ree.lib.Config</resource-env-ref-type>
</resource-env-ref>
ibm-web-bnd.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-bnd xmlns="http://websphere.ibm.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-web-bnd_1_0.xsd" version="1.0">
<resource-env-ref name="MyConstants" binding-name="rep/dev/app1/MyResourceReference" />
</web-bnd>
之后你可以使用JNDI查找java:comp/env/MyConstants并获取Config对象。