0

I have a SpringBoot app that is on spring-boot 1.3.8. Which comes with Spring 4.2.8 by default.

SonarQube wants my rest api controller to use @GetMapping instead of @RequestMapping(method = RequestMethod.GET). This requires Spring 4.3.

So I tried to exclude spring-web and spring-webmvc 4.2.8 from spring-boot-starter-web and include spring-web and spring-webmvc 4.3.2.

As soon as I did that, my MockMvcBuilders.standaloneSetup(stateController).build() started to fail with this error

    NoSuchMethodError org.springframework.aop.support.AopUtils.selectInvocableMethod

Has anyone run into this and how did you fix it?

Thanks!

Karl

    @Before
    public void setUp() {
        try {
            MockitoAnnotations.initMocks(this);
            this.mockMvc = MockMvcBuilders.standaloneSetup(stateController).build();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
<dependency>
 <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <exclusions>
            <exclusion>
                <groupId>org.springframework</groupId>
                <artifactId>spring-web</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.springframework</groupId>
                <artifactId>spring-webmvc</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>4.3.2.RELEASE</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>4.3.2.RELEASE</version>
    </dependency>
ky2ninh
  • 31
  • 1
  • 1
  • 7
  • Don't please don't.. This will only lead to issues. Don't mix versions of jars from different versions of Spring. Spring boot 1.3 requires Spring 4.2 don't throw 4.3 jars in there. If you want to use those annotations upgrade Spring Boot to a version that uses 4.3 (also Spring Boot 1.3 hs long been deprecated and hasn't received any support nor do the framework versions used by Spring Boot 1.3). – M. Deinum Feb 03 '22 at 07:33

0 Answers0