Spring 数据访问 之 JNDI

本文介绍如何在Spring框架中配置并使用JAVAEE应用服务器提供的JNDI数据源,包括使用JndiObjectFactoryBean及简化配置的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Many Java EE application servers build in data source implementations that you can configure from
the server console or in configuration files. If you have a data source configured in an application server
and exposed for JNDI lookup, you can use JndiObjectFactoryBean to look it up.
很多JAVA EE应用服务器都有内建的DataSource实现 我们可以通过服务器控制台或者配置文件来进行设置,如果你有一个配置好的应用服务器的datasource并且暴露给了JNDI来进行查找,那么你可以使用JndiObjectFactoryBean来找到它


<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="jdbc/VehicleDS" />
</bean>


In Spring, a JNDI lookup can be simplified by the jndi-lookup element defined in the jee sjee schema.
在Spring里 通过使用JEE Schema定义的jndi-lookup元素来设置一个JNDI查找是很简单的事情。

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

<jee:jndi-lookup id="dataSource" jndi-name="jdbc/VehicleDS" />
...
</beans>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值