Spring Boot does not load test configuration correctly when starting from eclipse + gradle

When I launch the Spring Boot application from Eclipse (STS) as a “Java application” or as a “Spring Boot App”, the application does not work because it is trying to load configurations (@Configuration) from the test path .

The fact is that it works correctly for building based on maven, but not for gradle.

The only workaround that I see is to rename the test package to something else to hide it from scanning the path.

In general, the question arises: how to make it work correctly? I would suggest that the SpringToolSuite team encounters this problem daily or that I am doing something wrong.

Here's a test project that works when importing like maven, but with an error when importing gradle: https://github.com/mabn/spring-boot-integration-test

I am using STS 3.7.1

+3
eclipse spring-boot spring-tool-suite gradle
source share
1 answer

The fact is that it works correctly for building based on maven, but not for gradle.

Yes, unfortunately, this is so. Gradle does not work correctly with setting the path to the eclipse runtime. This is even the case with Gradle's own new plugin for the BuildShip plugin.

See this question I raised recently: https://bugs.eclipse.org/bugs/show_bug.cgi?id=482315

The resolved error that you found is indeed resolved, but it only concerns the maven / m2e case, which is actually fixed (m2e does it correctly for "Run As → Java Project", and we applied a similar fix for "Run As → Spring Boot App "). However, this fix is ​​maven-specific, since the Gradle case is not actually fixed until this issue is resolved:

https://issues.gradle.org/browse/GRADLE-1777

+2
source share

All Articles