I have set up empty project with application class only (I'm using Kotlin, but i'm sure that's not a root cause)
I have following gradle.build.kts file:
```import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins { id("org.springframework.boot") version "2.5.3" id("io.spring.dependency-management") version "1.0.11.RELEASE" kotlin("jvm") version "1.5.21" kotlin("plugin.spring") version "1.5.21" }
group = "com.example" version = "0.0.1-SNAPSHOT" java.sourceCompatibility = JavaVersion.VERSION_11
repositories { mavenCentral() }
extra["springCloudVersion"] = "2020.0.3"
dependencies { implementation("org.springframework.boot:spring-boot-starter-amqp") implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter-actuator")
implementation("org.springframework.cloud:spring-cloud-starter-bootstrap")
implementation("org.springframework.boot:spring-boot-starter")
implementation("org.springframework.retry:spring-retry")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
implementation("org.springframework.cloud:spring-cloud-stream")
implementation("org.springframework.cloud:spring-cloud-stream-binder-rabbit")
testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("org.springframework.amqp:spring-rabbit-test")
}
dependencyManagement { imports { mavenBom("org.springframework.cloud:spring-cloud-dependencies:${property("springCloudVersion")}") } }
tasks.withType
tasks.withType
And application class:
```@SpringBootApplication
class DemoApplication
fun main(args: Array<String>) {
runApplication<DemoApplication>(*args)
}
If I run it like that, the app starts fine. But if I add any Spring component which injects org.springframework.core.convert.ConversionService, app startup fails with following error:
```***** APPLICATION FAILED TO START
Description:
Parameter 0 of constructor in com.example.demo.Test required a single bean, but 2 were found: - mvcConversionService: defined by method 'mvcConversionService' in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class] - integrationConversionService: defined in null
Example of such class:
@Repository class Test(val cs: ConversionService) { } ```
P.S. Can someone suggest any temp workaround before proper fix will be released?
Comment From: wilkinsona
There are two ConversionService
beans in your app:
mvcConversionService
integrationConversionService
The former is used by Spring MVC and the latter by Spring Integration.
You are trying to inject a ConversionService
but you haven’t indicated which one so your injection point is ambiguous. As a result, the application fails to start. You need to provide more information to indicate which conversion service you want to inject. You could use @Qualifier
, for example @Qualifier("mvcConversionService")
, to do this.