Autowiring BuildProperties bean from Gradle - NoSuchBeanDefinitionException

The problem I had may have been different, but I landed here trying to google the solution, so I'll post this here in case anybody else runs into the same problem. My error message was:

Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.boot.info.BuildProperties' available

It was only when trying to run within IntelliJ, not when run with gradle from the command line. (AND this is possibly specific to SpringBoot)

I just needed to set "Delegate IDE build/run actions to gradle" from within "Build, Execution, Deployment->Build Tools->Gradle" which then got the "bootBuildInfo" task to run when building from the IDE.


For a Maven project, in IntelliJ "Preferences...", under Build, Execution, Deployment > Build Tools > Maven > Runner, select the option "Delegate IDE build/run actions to Maven."