Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-10412

Unable to exclude CamelAutoConfiguration in Spring Boot



    • Improvement
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 2.18.0
    • 2.19.0
    • camel-spring-boot
    • None
    • Unknown


      Prior to 2.18.0, you could exclude CamelAutoConfiguration in unit tests and no camel context would start up. This is useful for testing things in isolation that does not need camel and is a standard thing to do in Spring Boot since by default it auto configures everything it can find.

      Now with 2.18.0, there has been a lot more auto configuration classes added and required to be excluded. Virtually every *AutoConfiguration class found in camel-core-starter needs to be excluded. This is not practical to do.

      I have edited one file DirectComponentAutoConfiguration and added this line @ConditionalOnBean(CamelAutoConfiguration.class)

      and with my unit test, I can see it no longer tries to pull in that component.

      public class PlainTest {
      	@EnableAutoConfiguration(exclude = { CamelAutoConfiguration.class
      			// , DirectComponentAutoConfiguration.class, DirectVmComponentAutoConfiguration.class,
      			// LogComponentAutoConfiguration.class, PropertiesComponentAutoConfiguration.class, RestComponentAutoConfiguration.class,
      			// SchedulerComponentAutoConfiguration.class, SedaComponentAutoConfiguration.class, StubComponentAutoConfiguration.class,
      			// ValidatorComponentAutoConfiguration.class, VmComponentAutoConfiguration.class, XsltComponentAutoConfiguration.class,
      			// GzipDataFormatAutoConfiguration.class, SerializationDataFormatAutoConfiguration.class, StringDataFormatAutoConfiguration.class,
      			// ZipDataFormatAutoConfiguration.class, BeanLanguageAutoConfiguration.class, ConstantLanguageAutoConfiguration.class,
      			// HeaderLanguageAutoConfiguration.class
      	public static class Config {
      	public void test() {
      		// do something

      Unfortunately I cannot put this into git and commit since I see at the top of the DirectComponentAutoConfiguration file

      Generated by camel-package-maven-plugin - do not edit this file!

      I'm not sure what to edit to get this to auto generate correctly with the changes required so I'll leave it to you guys.

      Don't forget to update the camel-core-starter/pom.xml file and add the camel-spring-boot dependency in.




            davsclaus Claus Ibsen
            mtran Minh Tran
            0 Vote for this issue
            2 Start watching this issue