Single bean, but 2 were found

I upgraded from gradle 6.7 to gradle 7.3.3. When attempting to run the project, it fails at startup with the following message:

Parameter 1 of method *** required a single bean, but 2 were found

  • gradle.properties in gradle 6.7 all my dependencies were either compile, compileOnly or runtime
  • gradle.properties in gradle 7.3.3 all my dependencies changed compile to implementation, compileOnly stayed the same and changed runtime to runtimeOnly

I would prefer to not have to make annotation changes, are there other options to correct this?

What you’ve mentioned is a Spring issue. If there’s two conflicting bean definitions and no qualifiers to identify which one you need to use in this particular case, that’s a problem, but you haven’t provided anything to help identify the, “why?” part of this. You’ll at least need to have some idea of what the bad output is that we’re trying to fix by changing the Gradle build.

For example, does the app built with the newer version contain an additional dependency that wasn’t there before or are there project files that were excluded previously, but are now included? It’s almost impossible to tell you what you could change in your Gradle build to eliminate a Spring error that could be caused by a number reasons. It’s possible that you can make a minor change in the build to fix it, but it’s also possible the application implementation is wrong and the earlier Gradle version had a bug that masked it. The best data would be what’s the difference between the artifact built with 6.7 vs. 7.3.3.