如何在web.xml中引用websphere资源环境提供程序?

时间:2014-09-15 01:29:10

标签: java xml websphere web.xml

我们使用资源环境提供程序在websphere中定义了自定义属性,该提供程序是使用

上的说明设置的
  

http://www.ibm.com/developerworks/websphere/library/techarticles/0611_totapally/0611_totapally.html

在第6节的那篇文章中,它说"For a Web module, open the web.xml file (for an EJB module, open the ejb-jar.xml file ) using the deployment descriptor editor."

我需要手动编辑web.xml,因为此时我无法使用IBM开发工具。是否有某些文档可以提供GUI创建的xml片段?谷歌在这一点上让我失望

1 个答案:

答案 0 :(得分:4)

您可以手动将其添加到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对象。