Maven 无法识别 Swagger 依赖项

Akk*_*rek 5 java maven swagger swagger-ui springfox

我正在尝试将 springfox/swagger 添加到我的 Spring Boot 应用程序中,但是当添加到 pom 文件中时,maven 无法识别依赖项的版本。不幸的是我找不到其背后的原因。这是我的 pom 文件的片段:

    <dependency>
        <groupId>io.springfox</groupId>
        <artifactId>springfox-swagger2</artifactId>
        <version>2.9.2</version>
    </dependency>
    <dependency>
        <groupId>io.springfox</groupId>
        <artifactId>springfox-swagger-ui</artifactId>
        <version>2.0.2</version>
    </dependency>
Run Code Online (Sandbox Code Playgroud)

版本标记为红色,表示 Maven 无法识别。这种行为背后的原因可能是什么?我正在使用 Maven 3.3.9。

Mat*_*ldi 4

这些工件存在于 Maven 存储库中,因此您应该能够将它们添加为依赖项。造成此行为的可能原因有以下三种:

  1. 您已在pom.xml.
  2. 您的 IDE 中有一个自定义的 Maven 配置。
  3. 您已经在 Maven 配置文件中定义了自定义存储库列表(如果您使用类似Nexus提供库的内容,则可能会发生这种情况)settings.xml

我还检查了Springfox Reference,您可以直接添加此自定义存储库:

<repositories>
    <repository>
      <id>jcenter-snapshots</id>
      <name>jcenter</name>
      <url>https://jcenter.bintray.com/</url>
    </repository>
</repositories>
Run Code Online (Sandbox Code Playgroud)