我正在嘗試將獨立應用程序部署到CloudFoundry。我在我的main
-method中使用Spring ApplicationContext
來初始化Spring,我有一個簡單的Bean來處理RabbitMQ的消息傳遞。Cloudfoundry:使用Spring和RabbitMQ部署獨立應用程序
在spring.xml
我已經配置的RabbitMQ和在POM文件我已經添加了必要的依賴關係cglib-nodep
,spring-rabbit
和cloudfoundry-runtime
。我進一步使用maven-assembly-plugin
插件創建了一個包含所有庫的單個jar文件,然後使用vmc
-tool將它部署到cloudfoundry。
當我部署jar
-file到CloudFoundry我收到以下錯誤:
Exception in thread "main" org.springframework.beans.factory.parsing.BeanDefinitionParsingException:
Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace
[http://www.springframework.org/schema/context]
Offending resource: class path resource [spring.xml]
[stacktrace ommited]
這裏是我的spring.xml
:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:rabbit="http://www.springframework.org/schema/rabbit"
xmlns:cloud="http://schema.cloudfoundry.org/spring"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/rabbit
http://www.springframework.org/schema/rabbit/spring-rabbit-1.0.xsd
http://schema.cloudfoundry.org/spring
http://schema.cloudfoundry.org/spring/cloudfoundry-spring-0.7.xsd">
<context:component-scan base-package="mypackage" />
<!-- Obtain a connection to the RabbitMQ via cloudfoundry-runtime: -->
<cloud:rabbit-connection-factory id="connectionFactory"/>
<!-- Set up the AmqpTemplate/RabbitTemplate: -->
<rabbit:template connection-factory="connectionFactory"/>
<!-- Request that queues, exchanges and bindings be automatically
declared on the broker: -->
<rabbit:admin connection-factory="connectionFactory"/>
<!-- Declare the "messages" queue: -->
<rabbit:queue name="messages" durable="true"/>
</beans>
而且Maven的組裝插件的配置:
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>at.ac.tuwien.infosys.dse2013s.group17.allocator.ui.StartUpAllocator</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
可能是什麼原因以上錯誤?如何配置maven-assembly-plugin,或者在spring.xml中確實存在問題嗎?
更新
我能夠解決的錯誤,通過將彈簧方面依賴於我的根POM作爲託管依賴,然後從我的模塊引用它,而不version元素。現在我得到了同樣的錯誤,但是這次異常抱怨http://schema.cloudfoundry.org/spring模式。