java.lang.TypeNotPresentException: Type org.springframework.test.context.junit.jupiter.SpringExtension not present
时间: 2023-09-25 16:13:18 浏览: 389
The `java.lang.TypeNotPresentException` is thrown when the requested class or interface is not present at runtime. In this case, it means that the `SpringExtension` class from the `org.springframework.test.context.junit.jupiter` package cannot be found.
To fix this issue, make sure that you have included the required Spring dependencies in your project's build path or dependency management tool, such as Maven or Gradle. Specifically, you need to include the `spring-test` library, which contains the `SpringExtension` class.
If you are using Maven, add the following dependency to your `pom.xml` file:
```
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
<scope>test</scope>
</dependency>
```
If you are using Gradle, add the following dependency to your `build.gradle` file:
```
dependencies {
testImplementation 'org.springframework:spring-test:${spring.version}'
}
```
Replace `${spring.version}` with the version of Spring that you are using in your project.
阅读全文