Hello,

I have recently tried to migrate from Spring Boot 3.1.4 to 3.2.2.

I have noticed that one of our tests is failing. I am using Java configuration to create a @RestController. The bean is created and looks similar to the one in previous versions, but the endpoint is not exposed anymore.

I have a configuration that defines a bean, and the annotation for RestController is inside.

@Slf4j
@Configuration
public class VersionControllerConfiguration {

  @Bean
  public VersionController versionController(AutowireCapableBeanFactory beanFactory) {

    @RestController
    class VersionControllerBean extends VersionController {
    }

    VersionControllerBean featureBean = new VersionControllerBean();
    beanFactory.autowireBean(featureBean);

    log.info(" *** Started SpringBoot application with versionController ");
    return featureBean;
  }
}

The real controller looks like this :

@Setter
@NoArgsConstructor
public class VersionController {

  @GetMapping("/version")
  public String mavenVersion() {
    return "should work";
  }

}

If I try to see all the beans having @RestController annotation, I can see the versionController bean.

Arrays.asList(applicationContext.getBeansWithAnnotation(RestController.class)).stream().sorted().forEach(System.out::println);

devKitController=com.ses.satapps.rest.controller.DevKitController@73c6ebec versionController=com.ses.satapps.rest.configuration.VersionControllerConfiguration$1VersionControllerBean@59e67a18 openApiResource=org.springdoc.webmvc.api.OpenApiWebMvcResource@4ad57db1 swaggerConfigResource=org.springdoc.webmvc.ui.SwaggerConfigResource@19240b9

The implementation is based on this Stack Overflow thread.

Considering the above, I have reached the conclusion that the binding annotations for REST are being somehow ignored starting with 3.2.1 (it still works in 3.2.0).

Can you tell me if the behavior is normal, done on purpose or not?

Thank you

Comment From: simonbasle

@PopescuMarius I've tried to assemble a local reproducer from your two snippets and make it fail, but I see no behavior difference whether I use Spring Boot 3.2.0 or 3.2.2... The fact that you can see the versionController bean when executing your last line of code, but the endpoint isn't there is also very weird.

Can you expand on your test case classes setup, and also provide more details on how you test the presence of the endpoint? Ideally, a minimal Java project (ie. only dependencies on Spring Framework and Spring Boot) which reproduces the issue would be appreciated.

Comment From: spring-projects-issues

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

Comment From: PopescuMarius

test case classes setup, and also provide more details on how you test the presence of the endpoint

tks for the feedback. I was on holiday, I will provide a sample as soon as possible(I hope tomorrow)

Comment From: PopescuMarius

@simonbasle I have tried to recreate it using Spring Initializr but it works with both versions of Spring Boot. I can see the bean and I can also access the endpoint. Something else must be interfering. Thank you.

Comment From: snicoll

Alright, let's close this then. We can reconsider if you can provide the sample.