Spring 数据访问 之 JNDI

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>

你可能感兴趣的:(spring)