Swagger 3和Java> = 9拼图

问题描述

在基于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] -------------------------------------------------------------

我猜错了,但我找不到。有人可以帮我吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)