spring-boot-starter-test NoSuchMethodError: org.junit.platform.commons.util.ReflectionUtils

springboot 做local UT的时候 出现以下报错,

spring-boot-starter-test NoSuchMethodError: org.junit.platform.commons.util.ReflectionUtils

这是因为 使用 spring-boot-starter-test 引入Junit的时候出现版本冲突
解决的办法是 :在 spring-boot-starter-test 中排除 落后的低版本,重新引入高版本的jar即可。

<properties>
      <java.version>1.8java.version>
      <junit-jupiter.version>5.0.0-M4junit-jupiter.version>
      <junit.platform.version>1.0.0-M4junit.platform.version>
      <junit.vintage.version>4.12.0-M4junit.vintage.version>
   properties>
<dependency>


            <groupId>org.springframework.bootgroupId>
            <artifactId>spring-boot-starter-testartifactId>
            <version>2.3.3.RELEASEversion>
            <scope>testscope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintagegroupId>
                    <artifactId>junit-vintage-engineartifactId>
                exclusion>
                <exclusion>
                    <artifactId>junit-jupiter-apiartifactId>
                    <groupId>org.junit.jupitergroupId>
                exclusion>
                <exclusion>
                    <artifactId>junit-jupiter-engineartifactId>
                    <groupId>org.junit.jupitergroupId>
                exclusion>
            exclusions>
        dependency>


        <dependency>
            <groupId>junitgroupId>
            <artifactId>junitartifactId>
            <version>4.13version>
            <scope>testscope>
        dependency>

        <dependency>
            <groupId>com.h2databasegroupId>
            <artifactId>h2artifactId>
            <scope>testscope>
        dependency>

        <dependency>
            <groupId>org.junit.platformgroupId>
            <artifactId>junit-platform-launcherartifactId>
            <version>${junit.platform.version}version>
            <scope>testscope>
        dependency>
        <dependency>
            <groupId>org.junit.jupitergroupId>
            <artifactId>junit-jupiter-engineartifactId>
            <version>${junit-jupiter.version}version>
            <scope>testscope>
        dependency>
        <dependency>
            <groupId>org.junit.vintagegroupId>
            <artifactId>junit-vintage-engineartifactId>
            <version>${junit.vintage.version}version>
            <scope>testscope>
        dependency>

你可能感兴趣的:(spring-boot-starter-test NoSuchMethodError: org.junit.platform.commons.util.ReflectionUtils)