THE problem
My java project doesn't run in Eclipse when I use this springboot plugin springboot-gradle-plugin
It throws this exception
Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
[2020-02-09 15:45:27.825] - 12256 GRAVE [main] --- org.springframework.boot.diagnostics.LoggingFailureAnalysisReporter:
***************************
APPLICATION FAILED TO START
***************************
Description:
Constructor in com.example.demo.VersionController required a bean of type 'org.springframework.boot.info.BuildProperties' that could not be found.
- Bean method 'buildProperties' in 'ProjectInfoAutoConfiguration' not loaded because @ConditionalOnResource did not find resource '${spring.info.build.location:classpath:META-INF/build-info.properties}'
A sample project with the issue
A sample repository with this issue can be found here:springboot-gradle-plugin-issue
To see this issue you need to run this project with Eclipse (I run it with eclipse 2019-09)
What this project does
This java project uses gradle with this plugin spring-boot-gradle-plugin.
This project prints in console the application version declared in my build.gradle file.
In my gradle.build file I include this lines:
springBoot {
buildInfo()
}
This lines all it does is adds a Gradle Task called 'bootBuildInfo' into gradle and while running this task it creates this file META-INF/build-info.properties.
In Java, when running the App, springboot automatically loads and reads META-INF/build-info.properties to create a bean.
The problem with Eclipse
All this works when I build with gradle in a terminal and run the generated jar file, but it does not work when I run my application through Eclipse.
It doesn't create the file META-INF/build-info.properties and when springboot tries to load it up throws a bean not found exception because it couldn't find the file.
Workarounds found
The project will run if I do one of the followings:
- manually create META-INF/build-info.properties under src/main/resources folder
- manually create META-INF/build-info.properties under build/resources/main folder
None of this aproaches are desired because it doesn't updates build-info.properties automatically