How can I setup my camel projects to completely rely on the Spring Dependency injection system while being xml free using the maven camel run plugin. I have tried a ton of configurations, but I still seem to be stuck with a "shell context" file that just imports my java configuration file. Is there anyway to get rid of this? Note: also on latest camel version of 2.17.1
Camel Route
@Component
public class TestRoute extends SpringRouteBuilder {
@Override
public void configure() throws Exception {
from("timer://foo?repeatCount=1")
.log("Hello World");
}
}
Java Config
@Configuration
@ComponentScan("com.mcf.xml.free.route")
public class RouteJavaConfig extends CamelConfiguration {
}
Maven Camel Plugin
<plugin>
<groupId>org.apache.camel</groupId>
<artifactId>camel-maven-plugin</artifactId>
<version>${camel.version}</version>
<configuration>
<configClasses>com.mcf.xml.free.config.RouteJavaConfig</configClasses>
</configuration>
</plugin>
Plugin Context that lets it all work that I want to get rid of.
<?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"
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.xsd">
<context:annotation-config/>
<bean class="com.mcf.xml.free.config.RouteJavaConfig"/>
</beans>
Is there some way to have the maven camel run plugin accept the Java Config instead of a Spring Context file? Also I haven't tested this yet, but If removing this file is going to cause an issue deploying to Apache Karaf is there a way to have it configured to use my Java Config as well?
You can start your Spring Java Config application using a main class you create yourself, and then use the java-maven-exec plugin to run it. This example has no XML file at all.
There is an example as part of Apache Camel at: https://github.com/apache/camel/tree/master/examples/camel-example-spring-javaconfig