我試圖在Liberty Profile中運行現有的WebSphere應用程序,但遇到了問題。該應用程序具有在服務器中配置的資源環境條目,我需要將其轉換爲Liberty Profile資源。我如何在server.xml中配置JNDI資源,它不是數據源(dataSource)或常量(jndiEntry)?在Liberty Profile中配置非數據源的JNDI資源
非常感謝
我試圖在Liberty Profile中運行現有的WebSphere應用程序,但遇到了問題。該應用程序具有在服務器中配置的資源環境條目,我需要將其轉換爲Liberty Profile資源。我如何在server.xml中配置JNDI資源,它不是數據源(dataSource)或常量(jndiEntry)?在Liberty Profile中配置非數據源的JNDI資源
非常感謝
您可以使用server.xml中的元素進行配置。這在infocenter中有記錄。本質上,你可以使用下面的命令啓用server.xml中的jndi功能:
<featureManager>
<feature>jndi-1.0</feature>
</featureManager>
然後你可以配置JNDI條目。你只能用這個做簡單的類型,所以沒有複雜的對象。要配置您的輸入你再這樣做:
<jndiEntry jndiName="myProp/philosopher" value="plato" />
的自由輪廓確實類型推斷,因此,如果您表示這樣的:
<jndiEntry jndiName="myProp/philosopher" value="1234" />
你從JNDI的號碼。如果你這樣表達:
<jndiEntry jndiName="myProp/philosopher" value="1234.3D" />
你得到一個雙。
如果你想一個數字作爲一個字符串文字,你會用引號表達出來:
<jndiEntry jndiName="myProp/philosopher" value='"1234.3D"' />
爲了得到這個從你的應用程序,你可以做一個全局查找,如:
Context ctx = new InitialContext();
Object jndiConstant = ctx.lookup("myProp/philosopher");
String philosopher = (String) jndiConstant;
你也可以將其映射到ibm-web-bnd.xml文件中的資源環境條目:
<env-entry name="philosopher" binding-name="myProp/philosopher" />
然後使用以下代碼查看它:
Context ctx = new InitialContext();
Object jndiConstant = ctx.lookup("java:comp/env/philosopher");
String philosopher = (String) jndiConstant;
目前,這對於Liberty Profile是不可能的。 IBM WasDev論壇回答了此問題https://developer.ibm.com/answers/questions/6221/resource-environment-entries-in-liberty-profile/?community=wasdev 已創建一個RFE流程(31525),以便在將來的版本中支持該流程。
在8.5.5.x有幾個新entries:
例如:要配置URL可以使用jndiURLEntry
這是一個好信息,但OP說:「[不]數據源( dataSource)或常量(jndiEntry)「。 –