2013-10-08 50 views
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类。我完全可能会感到困惑,并且有更好的方法来完成这一切!

+0

什么是你的问题将只检测呢?也许对使用Spring JPA进行更多的研究。对于使用camel-jpa来检查Camel文档,并且对camel-jpa进行单元测试也是有帮助的。 –

回答

1

ApplicationContext用@Configuration注释。

春天,如果你添加以下到您的春季-config.xml中

<context:component-scan base-package="<your base package>" /> 
相关问题