Spring的Autowire JNDI资源
问题内容:
我想知道如何使用注解在Spring控制器中自动装配JNDI资源。
目前,我可以使用
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="my/service"/>
</bean>
有什么办法,我可以使用注解来做同样的事情吗?像@Resource(name =“ my / service”)之类的东西?
问题答案:
我使用此配置来注入JNDI资源
弹簧配置
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
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.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/jee
http://www.springframework.org/schema/jee/spring-jee.xsd">
<jee:jndi-lookup id="destination" jndi-name="java:/queue/inbound/jndiname" />
</beans>
类
@Autowired
private javax.jms.Destination destination;