Reputation: 2335
utilI am trying to build a simple application that uses Apache Camel HL7 and Spring JPA. Currently my Spring JPA configuration is being done through an ApplicationContext class. Camel is being configured via xml. My web.xml is as follows:
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>
and spring-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>
and part of the 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 {
I am not sure how to correctly load the ApplicationContext class. It is quite possible that I am completely confused and that there is a better way to do all of this!
Upvotes: 1
Views: 1330
Reputation: 1013
The ApplicationContext is annotated with @Configuration.
Spring will only detect this if you add the following to your spring-config.xml
<context:component-scan base-package="<your base package>" />
Upvotes: 1