Maven无法解决对Google Firebase的依赖 [英] maven could not resolve dependencies on google firebase

查看:133
本文介绍了Maven无法解决对Google Firebase的依赖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在gitlab ci/cd docker映像上运行mvn clean install,并在下面抛出以下错误.

Am running mvn clean install on my gitlab ci/cd docker image and it throws the following error below.

[错误]无法在项目bootstrap.service上执行目标:无法解析项目com.sheeft:bootstrap.service:jar:0.0.1-SNAPSHOT的依赖项:无法在com.google.firebase:firebase上收集依赖项-admin:jar:6.10.0-> com.google.cloud:google-cloud-firestore:jar:1.9.0-> com.google.cloud:google-cloud-core-grpc:jar:1.79.0-> io.grpc:grpc-netty-shaded:jar:1.21.0-> io.grpc:grpc-core:jar:[1.21.0]:io.grpc:grpc-core:jar:[1.21没有可用的版本. 0]在指定范围内-> [帮助1]

[ERROR] Failed to execute goal on project bootstrap.service: Could not resolve dependencies for project com.sheeft:bootstrap.service:jar:0.0.1-SNAPSHOT: Failed to collect dependencies at com.google.firebase:firebase-admin:jar:6.10.0 -> com.google.cloud:google-cloud-firestore:jar:1.9.0 -> com.google.cloud:google-cloud-core-grpc:jar:1.79.0 -> io.grpc:grpc-netty-shaded:jar:1.21.0 -> io.grpc:grpc-core:jar:[1.21.0]: No versions available for io.grpc:grpc-core:jar:[1.21.0] within specified range -> [Help 1]

所以我在pom中尝试了以下内容

So I tried the following in my pom

<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.7.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.sheeft</groupId>
    <artifactId>bootstrap.service</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>Sheeft Bootstrap Service</name>
    <description>Demo project for Spring Boot</description>

    <properties>
        <java.version>1.8</java.version>
    </properties>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>io.grpc</groupId>
                <artifactId>grpc-core</artifactId>
                <version>1.23.0</version>
            </dependency>
            <dependency>
                <groupId>io.grpc</groupId>
                <artifactId>grpc-api</artifactId>
                <version>[1.23.0]</version>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>com.vaadin.external.google</groupId>
                    <artifactId>android-json</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <!-- 2fa -->
        <dependency>
            <groupId>org.jboss.aerogear</groupId>
            <artifactId>aerogear-otp-java</artifactId>
            <version>1.0.0</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.inlaks</groupId>
            <artifactId>inlaks-util-lib</artifactId>
            <version>1.0</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.apache.derby/derby -->
        <dependency>
            <groupId>org.apache.derby</groupId>
            <artifactId>derby</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
            <version>20160212</version>
            <type>jar</type>
        </dependency>
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
        </dependency>
        <dependency>
            <groupId>com.google.firebase</groupId>
            <artifactId>firebase-admin</artifactId>
            <version>6.10.0</version>
            <exclusions>
                <exclusion>
                    <groupId>io.grpc</groupId>
                    <artifactId>grpc-core</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>io.grpc</groupId>
                    <artifactId>grpc-api</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>io.grpc</groupId>
                    <artifactId>grpc-netty-shaded</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>io.grpc</groupId>
            <artifactId>grpc-core</artifactId>
            <version>1.23.0</version>
            <exclusions>
                <exclusion>
                    <groupId>io.grpc</groupId>
                    <artifactId>grpc-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>io.grpc</groupId>
            <artifactId>grpc-netty-shaded</artifactId>
            <version>1.23.0</version>
        </dependency>
        <dependency>
            <groupId>io.grpc</groupId>
            <artifactId>grpc-api</artifactId>
            <version>[1.23.0]</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>joda-time</groupId>
            <artifactId>joda-time</artifactId>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

所以错误现在有所不同,但是很奇怪

so the error is a bit different now but it is weird

[错误]无法在项目bootstrap.service上执行目标:无法解析项目com.sheeft:bootstrap.service:jar:0.0.1-SNAPSHOT的依赖项:无法在io.grpc:grpc-core上收集依赖项:jar:1.23.0-> io.grpc:grpc-api:jar:[1.23.0]:在指定范围内没有适用于io.grpc:grpc-api:jar:[1.23.0]的版本-> [帮助1]

[ERROR] Failed to execute goal on project bootstrap.service: Could not resolve dependencies for project com.sheeft:bootstrap.service:jar:0.0.1-SNAPSHOT: Failed to collect dependencies at io.grpc:grpc-core:jar:1.23.0 -> io.grpc:grpc-api:jar:[1.23.0]: No versions available for io.grpc:grpc-api:jar:[1.23.0] within specified range -> [Help 1]

关于上述错误的奇怪之处在于它实际上下载了如下所示的依赖项

what is weird about the above error is that it actually downloaded the dependency as seen below

从中央下载:

Downloading from central: https://repo.maven.apache.org/maven2/io/grpc/grpc-api/1.23.0/grpc-api-1.23.0.pom Downloaded from central: https://repo.maven.apache.org/maven2/io/grpc/grpc-api/1.23.0/grpc-api-1.23.0.pom (0 B at 0 B/s)

推荐答案

您明确引用了grpc-api versio 1.21.1,该版本表示来自grpc-core 1.23及其相关版本的瞬时依赖加载.你为什么要让他们与众不同? 如果您想这样保留它们,则必须从grpc-core中排除grpc-api.

You explicitly refere to grpc-api versio 1.21.1 which prefent transient dependecny load from grpc-core 1.23 with related version. Why do you want them different? If you wanna keep them like this you have to exclude grpc-api from grpc-core.

但是更容易处理的方法是为api和core保留一个版本.

But easier way to handle it is keep one version for api and core.

Maven范围语法: https://maven.apache.org/enforcer /enforcer-rules/versionRanges.html

Maven range syntax: https://maven.apache.org/enforcer/enforcer-rules/versionRanges.html

对于Core模块,只有严格的版本兼容性定义为:

For Core module it's only strict version compatibility defined as:

<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-api</artifactId>
<version>[1.23.0]</version>
<scope>compile</scope>
</dependency>

这篇关于Maven无法解决对Google Firebase的依赖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆