Spring的Autowire JNDI资源 [英] Autowire JNDI Resource in Spring

查看:82
本文介绍了Spring的Autowire JNDI资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何使用注释在Spring控制器中自动装配JNDI资源.

I would like to know how to autowire JNDI resource in Spring controller using annotation.

当前,我可以使用

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

有什么办法,我可以使用注解来做同样的事情吗?就像是 @Resource(name ="my/service")吗?

Is there any way, I can do the same thing using annotation? Something like @Resource(name="my/service") ?

推荐答案

我使用此配置来注入JNDI资源

I use this configuration to inject a JNDI resource

弹簧配置

<?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;

这篇关于Spring的Autowire JNDI资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆