我怎样才能设置我的骆驼项目完全依赖于Spring依赖注入系统,而使用maven骆驼运行插件是免费的xml。我已经尝试了大量的配置,但我似乎仍然只能导入我的java配置文件的“shell上下文”文件。无论如何摆脱这个?注:2.17.1也对最新版本的骆驼Camel Spring JavaConfig Maven-Camel-Plugin没有任何xml
骆驼路线
@Component
public class TestRoute extends SpringRouteBuilder {
@Override
public void configure() throws Exception {
from("timer://foo?repeatCount=1")
.log("Hello World");
}
}
Java的配置
@Configuration
@ComponentScan("com.mcf.xml.free.route")
public class RouteJavaConfig extends CamelConfiguration {
}
的Maven插件骆驼
<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>
插件上下文,让这一切工作我想摆脱。
<?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>
有没有办法让maven camel run plugin接受Java Config而不是Spring Context文件?此外,我还没有测试过,但如果删除此文件会导致部署到Apache Karaf的问题有一种方法来配置它以使用我的Java配置?
我问这是出于好奇。为什么你想要摆脱这个小文件? –
仅用于维护和重构目的。基于Xml的配置非常难以安全地用IDE工具重构。理想情况下,我的基础项目应该没有xml,除非它是用于某种遗留依赖项支持。我倾向于创建大量的应用程序,这些应用程序可能会进行大量的重构,因此清理任何会降低速度的应用程序是非常理想的。 –