简体   繁体   中英

Create DataSource using JBoss 7 JNDI and Spring

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.

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>

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"/>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM