When the annotation @SpringBean with Spring Cloud OpenFeign and SpEL is used then Spock refreshes Spring context and ConfigurationPropertiesBindingPostProcessor is not registered (also some other BeanPostProcessors are not registered as well), so, in my case, a value from the property test of ApplicationProperties.java is NOT replaced with a value of a propertyapplication.test from application-test.properties.
When the annotation @SpringBean is not used then the context is loaded with the post processor.
How to reproduce
ApplicationProperties.java
import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
@Getter
@Setter
@Component
@ConfigurationProperties(prefix = "application")
public class ApplicationProperties {
private boolean test = true;
private String url;
}
Can you provide an SSCCE? And does this only happen with feign or have you noticed it with other things too? Does this also happen with springs own @MockBean? Spocks implementation is based on that implementation.
Issue description
When the annotation @SpringBean with Spring Cloud OpenFeign and SpEL is used then Spock refreshes Spring context and ConfigurationPropertiesBindingPostProcessor is not registered (also some other BeanPostProcessors are not registered as well), so, in my case, a value from the property
test
ofApplicationProperties.java
is NOT replaced with a value of a propertyapplication.test
fromapplication-test.properties
.When the annotation @SpringBean is not used then the context is loaded with the post processor.
How to reproduce
ApplicationProperties.java
application-test.properties
AnotherAppRestClient.java
ApplicationSpec.groovy
When the anntation @SpringBean with the service is commented then the test passes.
It also works when I rewrite the Feign client with value replacement instead of SpEL for
url
parameter of the FeignClient annotation:Workaround
Use
${application.url}
instead of#{applicationProperties.url}
Additional Environment information
Java/JDK
java -version
Groovy version
groovy -version
Groovy Version: 2.5.8 JVM: 11.0.2 Vendor: Oracle Corporation OS: Mac OS X
Build tool version
Gradle
gradle -version
Operating System
Mac
IDE
IntelliJ
Build-tool dependencies used
Gradle/Grails