Create DataSource using JBoss 7 JNDI and Spring

浪子不回头ぞ 提交于 2020-01-23 18:01:09

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!