title: Spring Cloud Stream Configuration classes are not being loaded
body: <p>After updating from <code>Spring Boot 2.0.6</code> / <code>Spring Cloud Finchley.RELEASE</code> to <code>Spring Boot 2.1.3</code> / <code>Spring Cloud Greenwich.SR1</code>, I am experiencing a very odd configuration / component scanning issue.</p>
  
  <p>The application is structured as follows:</p>
  
  <ul>
  <li>main-application</li>
  <li>messaging-lib</li>
  <li>commons-lib</li>
  </ul>
  
  <p>Main application is annotated with <code>@SpringBootApplication(scanBasePackages = {"com.app.libs", "com.app"})</code>, where the <code>com.app</code> packages are those under the <code>main-application</code>, while <code>com.app.libs</code> are the packages of the libs.</p>
  
  <p>The <code>commons-lib</code> configuration which is simply a framework-esque library has the following main configuration entrypoint:</p>
  
  <pre><code>package com.app.libs.commons
  
  @Target(ElementType.TYPE)
  @Retention(RetentionPolicy.RUNTIME)
  @Documented
  @Inherited
  @Import(CommonsConfiguration.class)
  public @interface EnableCommons {
  }
  </code></pre>
  
  <p>With <code>CommonsConfiguration</code> having:</p>
  
  <pre><code>package com.app.libs.commons.config
  
  @Configuration
  @ConditionalOnProperty(value = "com.app.config.commons", matchIfMissing = true)
  @ComponentScan(basePackages = "com.app.libs.commons")
  public class FrameworkConfiguration {
  </code></pre>
  
  <p>This way, I can basically annotate a single configuration class in my <code>main-application</code> and have it pick up common beans.</p>
  
  <p>The <code>messaging-lib</code> configuration which uses Spring Cloud Stream has the following configurations:</p>
  
  <pre><code>@Configuration
  @Import({ CustomBinding.class })
  @PropertySource("classpath:kafka.properties")
  @EnableBinding(Source.class)
  @EnableAutoConfiguration
  public class BindingConfiguration {
  }
  </code></pre>
  
  <p>The cloud stream configuration is as follows:</p>
  
  <pre><code>spring.cloud.stream.bindings.output.destination=${spring.application.name}
  spring.cloud.stream.kafka.bindings.output.producer.sync=true
  spring.cloud.stream.default.group=${spring.application.name}
  spring.cloud.stream.default.producer.partitionCount=9
  spring.cloud.stream.default.producer.partitionKeyExpression=headers.entityId
  spring.cloud.stream.kafka.binder.autoAddPartitions=true
  spring.cloud.stream.kafka.binder.autoCreateTopics=false
  </code></pre>
  
  <p>When starting the application, the following error message is produced:</p>
  
  <pre><code>***************************
  APPLICATION FAILED TO START
  ***************************
  
  Description:
  
  Failed to bind properties under 'spring.cloud.stream.default.producer.partition-key-expression' to org.springframework.expression.Expression:
  
      Property: spring.cloud.stream.default.producer.partitionkeyexpression
      Value: headers.entityId
      Origin: "spring.cloud.stream.default.producer.partitionKeyExpression" from property source "class path resource [kafka.properties]"
      Reason: No converter found capable of converting from type [java.lang.String] to type [@com.fasterxml.jackson.databind.annotation.JsonSerialize org.springframework.expression.Expression]
  
  Action:
  
  Update your application's configuration
  </code></pre>
  
  <p>After some looking through the source code, I've noticed that the <code>SpelConverter</code> in question is the one that is supposed to be initialized in <code>SpelExpressionConverterConfiguration</code>. Indeed, if I add <code>@Import({ SpelExpressionConverterConfiguration.class })</code> or <code>@Import({ BindingServiceConfiguration })</code> (the <code>@Configuration</code> class that imports the <code>SpelExpressionConverterConfiguration</code>) to my <code>BindingConfiguration</code>, the converter seems to get initialized. However, another error is then produced:</p>
  
  <pre><code>***************************
  APPLICATION FAILED TO START
  ***************************
  
  Description:
  
  A component required a bean of type 'org.springframework.messaging.core.DestinationResolver' that could not be found.
  
  The following candidates were found but could not be injected:
          - Bean method 'binderAwareChannelResolver' in 'BindingServiceConfiguration' not loaded because @ConditionalOnBean (types: org.springframework.cloud.stream.binder.BinderTypeRegistry; SearchStrategy: current) did not find any beans of type org.springframework.cloud.stream.binder.BinderTypeRegistry
  
  
  Action:
  
  Consider revisiting the entries above or defining a bean of type 'org.springframework.messaging.core.DestinationResolver' in your configuration.
  </code></pre>
  
  <p>I'm not quite sure what seems to be going on. When debugging, it seems that both <code>BindingBeansRegistrar</code> and <code>BinderFactoryConfiguration</code> (the classes imported through <code>@EnableBinding</code>) are loaded - yet no scanning occurs and the rest of the component scanning simply does not seem to happen.</p>
  
  <p>I've tried importing the configuration classes and/or scanning the packages myself, but in both cases I am still missing the <code>DestinationResolver</code> bean, although it should have been initialized.</p>
  
  <p>I've noted that, prior to the update, there were also some issues: I had to import <code>BindingServiceConfiguration</code>, <code>BinderFactoryConfiguration</code>, and <code>SpelExpressionConverterConfiguration</code> manually as well. </p>
  
  <p>Would anybody have pointers as to what could be causing this issue?</p>
  
  <p><strong>EDIT</strong>: Here are the <code>build.grade</code> files (some includes are omitted for brevity):</p>
  
  <p><strong>Application <code>build.gradle</code></strong></p>
  
  <pre><code>apply from: new File(project(':scripts').projectDir, '/service-impl.gradle')
  
  dependencies {
      implementation project(':dependency-A')
      implementation project(':dependency-B')
      implementation project(':messaging-library')
  
      testImplementation 'org.springframework.cloud:spring-cloud-stream-test-support'
  }
  </code></pre>
  
  <p><strong><code>service-impl.gradle</code> contents:</strong></p>
  
  <pre><code>buildscript {
      apply from: new File(project(':buildscripts').projectDir, '/repositories.gradle') // Repository definitions
      apply from: new File(project(':buildscripts').projectDir, '/dm-boot.gradle') // DM via spring boot plugin
      apply from: new File(project(':buildscripts').projectDir, '/dm-versions.gradle') // DM versions
  }
  
  configurations {
      all*.exclude module: 'spring-boot-starter-tomcat'
      all*.exclude group: 'org.apache.bval'
  }
  
  artifacts {
      archives bootJar
  }
  
  dependencies {
      compileOnly 'org.projectlombok:lombok'
  
      compile 'org.springframework.boot:spring-boot-starter'
      compile 'org.springframework.boot:spring-boot-starter-web'
      compile 'org.springframework.boot:spring-boot-starter-jetty'
      compile 'org.springframework.boot:spring-boot-starter-actuator'
      compile 'org.springframework.boot:spring-boot-starter-cache'
      compile 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client'
  
      compile 'org.springframework.cloud:spring-cloud-starter-config'
  
      testCompile 'junit:junit'
      testCompile 'org.springframework.boot:spring-boot-starter-test'
  
      testCompileOnly 'org.projectlombok:lombok'
  
      compile 'net.logstash.logback:logstash-logback-encoder'
  }
  </code></pre>
  
  <p><strong>Commons Library <code>build.gradle</code></strong></p>
  
  <pre><code>apply from: new File(project(':buildscripts').projectDir, '/repositories.gradle') // Repository definitions
  apply from: new File(project(':buildscripts').projectDir, '/dm-plain.gradle') // DM via spring boot plugin
  apply from: new File(project(':buildscripts').projectDir, '/dm-versions.gradle') // DM versions 
  dependencies {
  
      api 'com.restfb:restfb:2.3.0'
      api 'commons-io:commons-io'
      implementation 'com.jcraft:jsch:0.1.54'
  
      //lombok
      compileOnly 'org.projectlombok:lombok'
  
      //spring
      implementation 'org.springframework.boot:spring-boot-starter-web'
      implementation 'org.springframework.boot:spring-boot-starter-jetty'
      implementation 'org.springframework.boot:spring-boot-starter-security'
      api 'org.springframework.security:spring-security-core'
      api 'org.springframework.security:spring-security-web'
      api 'org.springframework:spring-jdbc'
      api 'org.springframework.boot:spring-boot-starter-actuator'
  
      //thrift modules
      compileOnly 'com.facebook.swift:swift-codec'
      compileOnly 'com.facebook.swift:swift-service'
  
      //db modules
      api 'org.postgresql:postgresql'
      api 'org.flywaydb:flyway-core'
      api 'com.zaxxer:HikariCP'
      api 'org.jooq:jooq'
  
      //embedded pg modules
      compileOnly 'com.opentable.components:otj-pg-embedded'
  
      api group: 'net.minidev', name: 'json-smart', version: '2.2.1'
      api group: 'org.json', name: 'json', version: '20140107'
  
      //tests
      testImplementation 'junit:junit'
      testImplementation 'org.springframework.boot:spring-boot-starter-test'
      testImplementation 'com.opentable.components:otj-pg-embedded'
  
      testImplementation 'org.springframework.security:spring-security-core'
      testImplementation 'org.springframework.security:spring-security-web'
      testImplementation 'org.springframework.security:spring-security-config'
      testImplementation 'org.springframework:spring-jdbc'
      testImplementation 'org.springframework.boot:spring-boot-starter-actuator'
  
      testImplementation 'org.apache.sshd:sshd-core:1.7.0' // sftpFileTransfer testing - embedded sftp server
  
      testCompileOnly 'org.projectlombok:lombok'
      testCompileOnly 'javax.servlet:javax.servlet-api'
  
  
  }
  </code></pre>
  
  <p><strong>Messaging Lib <code>build.gradle</code></strong> (used as a standalone lib, hence does not use the above <code>.gradle</code> files)</p>
  
  <pre><code>buildscript {
      ext {
          springBootVersion = '2.1.3.RELEASE'
      }
      repositories {
          mavenCentral()
      }
      dependencies {
          classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
      }
  }
  
  apply from: new File(rootDir.parentFile, 'buildscripts/publish.gradle')
  apply from: new File(rootDir.parentFile, 'buildscripts/coverage.gradle')
  
  apply plugin: 'java'
  apply plugin: 'org.springframework.boot'
  apply plugin: 'io.spring.dependency-management'
  
  group = 'com.app.libs.messaging'
  version = '0.0.3'
  sourceCompatibility = 1.8
  targetCompatibility = 1.8
  
  repositories {
      mavenCentral()
      maven { url "https://repo.spring.io/snapshot" }
      maven { url "https://repo.spring.io/milestone" }
  }
  
  ext {
      springCloudVersion = 'Greenwich.SR1'
      jacksonVersion = '2.9.6'
      lombokVersion = '1.16.18'
      jooqVersion = '3.11.2'
      flywayVersion = '5.2.1'
  }
  
  dependencies {
  
      compile 'org.aspectj:aspectjweaver'
      compile 'org.springframework:spring-tx'
      compile 'org.springframework.cloud:spring-cloud-stream'
      compile 'org.springframework.cloud:spring-cloud-stream-binder-kafka'
      compile 'org.apache.commons:commons-lang3:3.5'
      compile 'org.javassist:javassist:3.22.0-GA'
      compile "org.flywaydb:flyway-core:${flywayVersion}"
  
      compileOnly "org.jooq:jooq:${jooqVersion}"
      compileOnly "org.projectlombok:lombok:${lombokVersion}"
  
      testCompileOnly "org.projectlombok:lombok:${lombokVersion}"
  
      testCompile 'org.springframework.boot:spring-boot-starter-test'
      testCompile 'org.springframework.boot:spring-boot-starter-json'
      testCompile 'org.springframework.cloud:spring-cloud-stream-test-support'
  
      testCompile "com.fasterxml.jackson.core:jackson-core:${jacksonVersion}"
      testCompile "com.fasterxml.jackson.core:jackson-databind:${jacksonVersion}"
  
      testCompile 'junit:junit:4.12'
      testCompile "org.jooq:jooq:${jooqVersion}"
      testCompile "org.flywaydb:flyway-core:${flywayVersion}"
  
      testCompile 'org.postgresql:postgresql:42.2.2'
      testCompile 'com.opentable.components:otj-pg-embedded:0.13.0'
      testCompile 'org.springframework:spring-jdbc'
  }
  
  dependencyManagement {
      // disable maven exclusion to enhance gradle import performance
      // https://github.com/spring-gradle-plugins/dependency-management-plugin/issues/153
      applyMavenExclusions = false
  
      imports {
          mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
      }
  }
  
  jar.enabled = true
  bootJar.enabled = false
  </code></pre>
  
  <p>I've tried to omit any files that I think should be unrelated. </p>