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

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

快速修正程式會新增 res-sharing-scope 元素 (如果尚未設定的話) ,並將連線定義為 Shareable .

以下是會標示的資源參照範例:
<resource-ref>
<description>
資料庫範例</description>
<res-ref-name>jdbc/exampleDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>儲存器</res-auth>
</resource-ref>


快速修正程式會新增 res-sharing-scope 元素:
<resource-ref>
<description>
資料庫範例</description>
<res-ref-name>jdbc/exampleDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>儲存器</res-auth>
<res-sharing-scope>可共用</res-sharing-scope>
</resource-ref>

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