1
工廠正在嘗試構建使用Apache Camel HL7和Spring JPA的簡單應用程序。目前我的Spring JPA配置是通過一個ApplicationContext類來完成的。駱駝正在通過xml進行配置。我的web.xml如下:如何使用xml正確配置Apache Camel和Spring JPA
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd「>
<display-name>Fusion Core HL7 Consumer</display-name>
<!-- location of spring xml files -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring-config.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>CamelServlet</servlet-name>
<servlet-class>org.apache.camel.component.servlet.CamelHttpTransportServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>CamelServlet</servlet-name>
<url-pattern>/camel/*</url-pattern>
</servlet-mapping>
<listener>
<listener-class>util.Startup</listener-class>
</listener>
和彈簧config.xml中:
<?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:camel="http://camel.apache.org/schema/spring"
xsi:schemaLocation="
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa-1.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
<import resource="camel-config.xml"/>
<!-- import resource="jpa-config.xml"/ -->
</beans>
和部分ApplicationContext中:
@Configuration
@EnableTransactionManagement
@ComponentScan(basePackages = { "au.com.incarta.fusion.core.repository" })
@PropertySource("classpath:application.properties")
@EnableJpaRepositories("au.com.incarta.fusion.core.repository")
public class ApplicationContext {
我不知道如何正確加載ApplicationContext類。我完全可能會感到困惑,並且有更好的方法來完成這一切!
什麼是你的問題將只檢測呢?也許對使用Spring JPA進行更多的研究。對於使用camel-jpa來檢查Camel文檔,並且對camel-jpa進行單元測試也是有幫助的。 –