2012-12-07 166 views
0

有人可以告訴我如何在SPRING MVC中配置JNDI名稱嗎?我使用的是jboss version7.1.1,DB是oracle 11g。我已經在jBoss服務器中定義了JNDI。如何在spring-servlet.xml中提及JNDI名稱?我嘗試了很多選擇,它不工作。我一直在獲取名稱未找到異常。春季JNDI MVC

+0

你想用JNDI做什麼?查找數據源? –

+0

@Philippe Marschall yes, – Suresh

回答

0
<jee:jndi-lookup id="dataSource" 
    jndi-name="java:jboss/datasources/ExampleDS" 
    expected-type="javax.sql.DataSource" /> 

其中jndi-name的值與您在JBoss中配置的值相匹配。你需要像這樣註冊jee命名空間:

<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns="http://www.springframework.org/schema/beans" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xmlns:jee="http://www.springframework.org/schema/jee" 
     xsi:schemaLocation="http://www.springframework.org/schema/beans  http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
      http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd"> 
+0

感謝您的幫助。這是JBOSS domain.xml的問題。我添加了驅動程序類,它工作正常。 – Suresh