【问题标题】:Could not resolve dependencies for project org.openapitools:openapi-generator-online:jar无法解析项目 org.openapitools:openapi-generator-online:jar 的依赖项
【发布时间】:2023-02-07 19:08:54
【问题描述】:

我想跑mvn 构建包我的 spring boot 项目的命令,但它给出了错误

我试过

1)maven更新项目
2)mvn -u 全新安装

仍然无法正常工作,请帮助我是 spring boot 的新手

错误

[错误] 无法在项目 openapi-generator-online 上执行目标: 无法解析项目的依赖关系 org.openapitools:openapi-generator-online:jar:6.3.0-SNAPSHOT: 失败 收集依赖项 org.openapitools:openapi-generator:jar:6.3.0-SNAPSHOT: 读取失败 工件描述符 org.openapitools:openapi-generator:jar:6.3.0-SNAPSHOT: 无法 传送神器 org.openapitools:openapi-generator:pom:6.3.0-SNAPSHOT 从/到 sonatype-快照 (https://oss.sonatype.org/content/repositories/snapshots):转账 失败了 https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator/6.3.0-SNAPSHOT/openapi-generator-6.3.0-SNAPSHOT.pom: PKIX 路径构建失败: sun.security.provider.certpath.SunCertPathBuilderException:无法 找到请求目标的有效证书路径 -> [帮助 1]

pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.openapitools</groupId>
        <artifactId>openapi-generator-project</artifactId>
        <!-- RELEASE_VERSION -->
        <version>6.3.0-SNAPSHOT</version>
        <!-- /RELEASE_VERSION -->
        <relativePath>../..</relativePath>
    </parent>
    <artifactId>openapi-generator-online</artifactId>
    <packaging>jar</packaging>
    <name>openapi-generator-online</name>
    <properties>
        <spring-boot.version>2.7.5</spring-boot.version>
        <springfox-version>3.0.0</springfox-version>
        <sonar.exclusions>**/org/openapitools/codegen/online/**/*</sonar.exclusions>
    </properties>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-dependencies</artifactId>
                <version>${spring-boot.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <build>
        <finalName>openapi-generator-online</finalName>
        <sourceDirectory>src/main/java</sourceDirectory>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
                <excludes>
                </excludes>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-checkstyle-plugin</artifactId>
                <configuration>
                    <configLocation>${project.parent.basedir}${file.separator}google_checkstyle.xml</configLocation>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>${spring-boot.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    <profiles>

        <profile>
            <id>static-analysis</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.github.spotbugs</groupId>
                        <artifactId>spotbugs-maven-plugin</artifactId>
                        <configuration>
                            <excludeFilterFile>${project.parent.basedir}${file.separator}spotbugs-exclude.xml</excludeFilterFile>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-pmd-plugin</artifactId>
                    </plugin>
                    <plugin>
                        <groupId>se.bjurr.violations</groupId>
                        <artifactId>violations-maven-plugin</artifactId>
                        <configuration>
                            <!-- Should be decreased regularly down to 0 as issues are fixed. -->
                            <maxViolations>3</maxViolations>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <!--SpringFox dependencies -->
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>${springfox-version}</version>
            <exclusions>
                <exclusion>
                    <groupId>io.swagger</groupId>
                    <artifactId>swagger-annotations</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>io.swagger</groupId>
                    <artifactId>swagger-models</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.google.guava</groupId>
                    <artifactId>guava</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <!-- Bean Validation API support -->
        <dependency>
            <groupId>jakarta.validation</groupId>
            <artifactId>jakarta.validation-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.openapitools</groupId>
            <artifactId>openapi-generator</artifactId>
            <version>${project.parent.version}</version>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>
</project>

【问题讨论】:

    标签: java spring-boot maven


    【解决方案1】:

    两个问题:

    第一个问题是你的 pom parent 不应该是 openapi-generator-project:

    <parent>
        <groupId>org.openapitools</groupId>
        <artifactId>openapi-generator-project</artifactId>
        <!-- RELEASE_VERSION -->
        <version>6.3.0-SNAPSHOT</version>
        <!-- /RELEASE_VERSION -->
        <relativePath>../..</relativePath>
    </parent>
    

    它应该是弹簧启动:

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>3.0.1</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    

    第二个问题:“PKIX 路径构建失败”是因为 openapi-generator-6.3.0-SNAPSHOT.pom 的 repo 位置 https://oss.sonatype.org 没有由您的 CACERTS 中的 CA 签名的证书。

    但是,如果您更改父级并且不在您的 openapi 和 openapi maven 插件依赖项中引用 SHAPSHOT(都在您的 pom 中丢失),那么它将从更常见的 https://repo1.maven.org 获取。

    【讨论】:

      猜你喜欢
      • 2017-03-03
      • 2021-01-04
      • 1970-01-01
      • 1970-01-01
      • 2017-05-06
      • 1970-01-01
      • 2013-09-23
      • 2012-01-26
      • 1970-01-01
      相关资源
      最近更新 更多