所以我开始了一个简单的Java 17和Spring 3新项目,其中有几个端点,首先,我又又招牌了,立刻我发现Swagger与Spring 3的新雅加达人不兼容。
比我决定使用Sprindocs的OpenAPI。它通过简单地添加依赖项来起作用:
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.0.2</version>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-api</artifactId>
<version>2.0.2</version>
</dependency>
资料来源:https://springdoc.org/v2/#javadoc-support
该项目正在编译并开始,但仍然有一个例外:
jakarta.validation.NoProviderFoundException: Unable to create a Configuration, because no Jakarta Bean Validation provider could be found. Add a provider like Hibernate Validator (RI) to your classpath.
因此,要解决这个问题,我必须添加雅加达验证API:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
p:在以下方面找到的解决方案:https://stackoverflow.com/questions/75418394/spring-boot-3-after-add-openapi-dependency-noproviderfoundexception