问题
I am first time making a webapp for Jboss server. For JBoss we have the jndi details, but I am wondering how to create the Datasource using it in spring application context.
If anyone has an example to create the connection, please share it.
回答1:
I will put this sample here.
just to show another way to do it.
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName">
<value>java:jboss/datasources/DSName</value>
</property>
</bean>
回答2:
I found the solution
Add below configuration to applicationContext.xml
xmlns:jee="http://www.springframework.org/schema/jee"
xsi:schemaLocation="http://www.springframework.org/schema/jee
http://www.springframework.org/schema/jee/spring-jee-3.0.xsd"
<jee:jndi-lookup expected-type="javax.sql.DataSource" id="dataSource" jndi-name="java:jboss/SAMPLE_JNDI"/>
来源:https://stackoverflow.com/questions/16663874/create-datasource-using-jboss-7-jndi-and-spring