0

I know this sound a bit weird but we run into an issue that when we add @EnableTransactionManagement in the application, all the controllers with @PreAuthorize are not accessible, the swagger cannot discover it and calling the API (with correct permission and role) will encounter 404 not found error.

To solve the issue, either remove the @EnableTransactionManagement in the application config or remove the @PreAuthorize in the controller, but either way is not an ultimate solution.

So I want to ask if any expert knows the cause of this and what we need to do to make things work, as we both need transaction and preauthorize in the app.

Frank
  • 569
  • 2
  • 6
  • 14
  • I would suggest you set your debugger to Trace for the controllers. It will show if the mappings are being mapped by using RequestMappingHandlerMapping to show the info. If you are using spring-boot set "logging.level.org.springframework.web=TRACE" in the application.properties. In the console it will log the mappings; i.e. com.user.UserController {GET /user/{userId}} – Rentius2407 Dec 07 '18 at 05:15
  • The following might help. http://forum.spring.io/forum/spring-projects/web/102350-requestmapping-and-preauthorize-not-compatible – Rentius2407 Dec 07 '18 at 05:28

1 Answers1

0

Turn out this can be solved by upgrading to spring boot version 2.x

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.1.1.RELEASE</version>
</parent>
Frank
  • 569
  • 2
  • 6
  • 14