【发布时间】:2021-02-03 01:34:48
【问题描述】:
我在基于 maven 的 Java11 应用程序上配置 Swagger 3 时遇到问题。
首先我在pom.xml中声明:
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>3.0.0</version>
</dependency>
然后,我使用 Spring Beans 配置 Swagger:
@Configuration
@EnableSwagger2
public class SwaggerConfig {
@Bean
public Docket swaggerSpringMvcPlugin() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.basePackage("com.***.***.controller.rest"))
.paths(PathSelectors.any())
.build()
.apiInfo(metaData());
}
private ApiInfo metaData() {
return new ApiInfoBuilder().title("***")
.description("***")
.contact(new Contact("**", "www.***.com", "**"))
.license("Apache 2.0")
.licenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html")
.version("1.0.0")
.build();
}
}
最后,我声明了module-info.java 要求:
requires springfox.swagger2;
requires springfox.spring.web;
requires springfox.core;
当我尝试mvn clean install 时,我收到以下错误:
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] error: the *** module reads package springfox.documentation.service from both springfox.core and springfox.spi
[ERROR] error: module springfox.spring.web reads package springfox.documentation.service from both springfox.spi and springfox.core
[ERROR] error: module springfox.swagger2 reads package springfox.documentation.service from both springfox.spi and springfox.core
[ERROR] error: module java.annotation reads package springfox.documentation.service from both springfox.spi and springfox.core
[ERROR] error: module spring.core reads package springfox.documentation.service from both springfox.spi and springfox.core
[ERROR] error: module java.validation reads package springfox.documentation.service from both springfox.spi and springfox.core
[ERROR] error: module spring.beans reads package springfox.documentation.service from both springfox.spi and springfox.core
[ERROR] error: module spring.web reads package springfox.documentation.service from both springfox.spi and springfox.core
[ERROR] error: module spring.context reads package springfox.documentation.service from both springfox.spi and springfox.core
[ERROR] error: module swagger.annotations reads package springfox.documentation.service from both springfox.spi and springfox.core
[ERROR] error: module spring.boot reads package springfox.documentation.service from both springfox.spi and springfox.core
[ERROR] error: module springfox.core reads package springfox.documentation.service from both springfox.spi and springfox.core
[ERROR] error: module springfox.spi reads package springfox.documentation.service from both springfox.core and springfox.spi
[ERROR] error: module spring.boot.autoconfigure reads package springfox.documentation.service from both springfox.spi and springfox.core
[ERROR] /private/tmp/***/src/main/java/module-info.java:[1] error: module *** reads package springfox.documentation.service from both springfox.core and springfox.spi
[INFO] 15 errors
[INFO] -------------------------------------------------------------
我猜错了,但我找不到。谁能帮帮我?
【问题讨论】:
-
在这里寻找问题 模块 A 从 X 和 Y 读取包 B
标签: spring-boot swagger java-11 java-9 springfox