Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/349.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java getDefaultDestination()返回空值_Java_Spring_Jms_Javabeans - Fatal编程技术网

Java getDefaultDestination()返回空值

Java getDefaultDestination()返回空值,java,spring,jms,javabeans,Java,Spring,Jms,Javabeans,我在eclipse(开普勒)中创建了动态web项目。在我的应用程序中,我使用了Spring、JMS、ActiveMQ和JSF。在我的java类中,使用以下代码获取BeanXML中的defaultdestination定义 import javax.jms.Message; import javax.jms.TextMessage; import org.springframework.jms.core.JmsTemplate; public class JmsReceiver { p

我在eclipse(开普勒)中创建了动态web项目。在我的应用程序中,我使用了Spring、JMS、ActiveMQ和JSF。在我的java类中,使用以下代码获取BeanXML中的defaultdestination定义

import javax.jms.Message;
import javax.jms.TextMessage;
import org.springframework.jms.core.JmsTemplate;


public class JmsReceiver {
    private JmsTemplate jmsTemplate;

public JmsTemplate getjmsTemplate() {

    return jmsTemplate;

}

public void setjmsTemplate(JmsTemplate jmsTemplate) {

    this.jmsTemplate = jmsTemplate;

}

public void processMessage() {


    System.out.println("DefaultDestination :"+jmsTemplate.getDefaultDestination());


}

}
我的bean定义是:

<bean id="defaultDestination" class="org.apache.activemq.command.ActiveMQQueue"></bean>

<bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">  
<property name="connectionFactory" ref="connectionFactory"></property>
<property name="defaultDestination"><ref bean="defaultDestination"/></property>
<property name="defaultDestinationName" value="myqueue"></property>  
</bean> 

但在运行“DefaultDestination:null”时。 请指导我解决此问题


<bean id="demoQueueDestination" class="org.apache.activemq.command.ActiveMQQueue">
    <constructor-arg><!-- 设置消息队列的名字 -->
         <value>Jaycekon</value>
    </constructor-arg>
</bean>   

ActiveMQDestination destination = (ActiveMQDestination) jmsTemplate.getDefaultDestination();
System.out.println(Thread.currentThread().getName() + " 向队列" + destination.getPhysicalName() + "发送消息---------------------->" + msg);
房祖康 ActiveMQDestination=(ActiveMQDestination)jmsTemplate.getDefaultDestination(); System.out.println(Thread.currentThread().getName()+)向队列" + destination.getPhysicalName()+“发送消息---------------------->“+味精);

房祖康
ActiveMQDestination=(ActiveMQDestination)jmsTemplate.getDefaultDestination();
System.out.println(Thread.currentThread().getName()+)向队列“+目的地。getPhysicalName()+”发送消息---------------------->“+味精);