在Java应用程序中集成Spring(Rabbit)?

时间:2015-12-21 14:28:23

标签: java spring spring-rabbit hivemq

我正在尝试将Spring集成到HiveMQ(MQTT代理)插件中。我已设法加载spring-context,并且实际上扫描了bean,并且可以使用@Inject代替@Autowire进行自动装配。

当我尝试在这个插件中使用Spring-Rabbit时,Spring框架抱怨它无法正确处理spring-context.xml中的xml。

  

引起:org.xml.sax.SAXParseException:cvc-complex-type.2.4.c:The   匹配通配符是严格的,但是找不到声明   元素'兔子:连接工厂'。

春天背景如下:

<?xml version='1.0' encoding='UTF-8'?>
<beans xmlns = 'http://www.springframework.org/schema/beans'
       xmlns:xsi = 'http://www.w3.org/2001/XMLSchema-instance'
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:rabbit="http://www.springframework.org/schema/rabbit"
       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-4.0.xsd
        http://www.springframework.org/schema/rabbit
        http://www.springframework.org/schema/rabbit/spring-rabbit.xsd'>

    <context:component-scan base-package="com.acme"/>

    <rabbit:connection-factory id="connectionFactory"
                               addresses='localhost'
                               username='username'
                               password='password'
                               virtual-host='vhost'/>

</beans>

我按如下方式加载上下文:

ClassLoader classLoader = this.getClass().getClassLoader();
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext();
ctx.setClassLoader(classLoader);
ctx.setConfigLocation("spring-context.xml");
ctx.refresh();

当我正常启动应用程序而没有HiveMQ插件的上下文时,它可以找到所需的一切。

任何提示在哪里寻找?

0 个答案:

没有答案
相关问题