在資源參照中設定共用範圍

此規則會標示在 WEB-INF/web.xml 檔中找到且遺漏 res-sharing-scope 元素的 resource-ref 元素。 Apache Tomcat 伺服器將資源共用範圍預設為 Shareable。 在 Java EE 中,資源共用範圍是定義為選用屬性。 原始檔掃描器提供了此規則的快速修正程式。 您可以使用快速修正程式,在 WebSphere Traditional 及 Liberty 中取得與 Tomcat 中相同的可共用範圍。

如果尚未設定 res-sharing-scope 元素,快速修正程式會新增它,並將連線定義成 Shareable

以下是會標示的資源參照範例:
<resource-ref>
<description>
Example Database</description>
<res-ref-name>jdbc/exampleDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>


快速修正程式會新增 res-sharing-scope 元素:
<resource-ref>
<description>
Example Database</description>
<res-ref-name>jdbc/exampleDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>

如需在 WebSphere Application Server 中共用資源連線的相關資訊,請參閱不能共用和可共用的連線