mvn依赖项:升级少数依赖项后,脱机失败

时间:2020-09-11 19:11:16

标签: java maven build

我将springboot从2.1.4.RELEASE升级到了2.3.3.RELEASE 更新了其他一些依赖项。 POM如下:

<?xml version="1.0" encoding="UTF-8"?>

4.0.0 com.gn 服务 1.0.0快照 罐子

<name>AbcXZ</name>
<description>AbcXZ Services</description>
<!--  
  <repositories>
    <repository>
      <id>groovy</id>
      <name>repo for groovy</name>
      <url>https://dl.bintray.com/groovy/maven/</url>
    </repository>
  </repositories> -->
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.3.3.RELEASE</version>
    <relativePath />
</parent>
<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>14</java.version>
</properties>
<dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>com.google.cloud</groupId>
      <artifactId>libraries-bom</artifactId>
      <version>4.3.0</version>
      <type>pom</type>
      <scope>import</scope>
    </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-data-redis</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>
    <dependency>
        <groupId>org.postgresql</groupId>
        <artifactId>postgresql</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>io.springfox</groupId>
        <artifactId>springfox-swagger2</artifactId>
        <version>2.7.0</version>
    </dependency>
    <dependency>
        <groupId>io.springfox</groupId>
        <artifactId>springfox-swagger-ui</artifactId>
        <version>2.7.0</version>
    </dependency>
    <dependency>
        <groupId>com.google.firebase</groupId>
        <artifactId>firebase-admin</artifactId>
        <version>7.0.0</version>
    </dependency>
      <dependency>
        <groupId>com.google.cloud</groupId>
        <artifactId>google-cloud-firestore</artifactId>
      </dependency>
    <dependency>
        <groupId>com.vladmihalcea</groupId>
        <artifactId>hibernate-types-52</artifactId>
        <version>2.4.2</version>
    </dependency>
    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-text</artifactId>
        <version>1.6</version>
    </dependency>
    <dependency>
        <groupId>org.flywaydb</groupId>
        <artifactId>flyway-core</artifactId>
        <version>6.0.0-beta</version>
    </dependency>
    <dependency>
        <groupId>com.twilio.sdk</groupId>
        <artifactId>twilio</artifactId>
        <version>7.36.0</version>
    </dependency>
    <dependency>
        <groupId>commons-beanutils</groupId>
        <artifactId>commons-beanutils</artifactId>
        <version>1.9.4</version>
    </dependency>
    <dependency>
        <groupId>org.modelmapper</groupId>
        <artifactId>modelmapper</artifactId>
        <version>2.3.0</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.kafka</groupId>
        <artifactId>spring-kafka</artifactId>
    </dependency>
        <!-- https://mvnrepository.com/artifact/org.json/json -->
    <dependency>
        <groupId>org.json</groupId>
        <artifactId>json</artifactId>
        <version>20200518</version>
    </dependency>   
    <dependency>
        <groupId>org.mnode.ical4j</groupId>
        <artifactId>ical4j</artifactId>
        <version>3.0.14</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>3.1.2</version>
            <executions>
                <execution>
                    <id>install-common-jar</id>
                    <phase>package</phase>
                    <goals>
                        <goal>jar</goal>
                    </goals>
                    <configuration>
                        <classifier>common</classifier>
                        <includes>
                            <include>**/common/**/*.class</include>
                        </includes>
                        <finalName>abcxz</finalName>
                    </configuration>
                </execution>
                <execution>
                    <id>create-data-jar</id>
                    <phase>package</phase>
                    <goals>
                        <goal>jar</goal>
                    </goals>
                    <configuration>
                        <classifier>data</classifier>
                        <includes>
                            <include>**/entity/**/*.class</include>
                            <include>**/repositories/**/*.class</include>
                            <include>**/repository/**/*.class</include>
                        </includes>
                        <finalName>abcxz</finalName>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-install-plugin</artifactId>
            <version>3.0.0-M1</version>
            <executions>
                <execution>
                    <id>install-common-jar</id>
                    <goals>
                        <goal>install-file</goal>
                    </goals>
                    <phase>install</phase>
                    <configuration>
                        <groupId>com.abcxz</groupId>
                        <artifactId>abcxz-common</artifactId>
                        <version>0.1</version>
                        <packaging>jar</packaging>
                        <file>${basedir}/target/abcxz-common.jar</file>
                        <generatePom>false</generatePom>
                    </configuration>
                </execution>
                <execution>
                    <id>install-data-jar</id>
                    <goals>
                        <goal>install-file</goal>
                    </goals>
                    <phase>install</phase>
                    <configuration>
                        <groupId>com.abcxz</groupId>
                        <artifactId>abcxz-data</artifactId>
                        <version>0.1</version>
                        <packaging>jar</packaging>
                        <file>${basedir}/target/abcxz-data.jar</file>
                        <generatePom>false</generatePom>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <release>14</release>
                <compilerArgs>
                    <arg>--enable-preview</arg>
                </compilerArgs>
                <forceJavacCompilerUse>true</forceJavacCompilerUse>
                <parameters>true</parameters>
            </configuration>
        </plugin>      
    </plugins>
</build>

此升级后。当我运行dependency:go-offline时,它失败并显示以下错误:

无法在项目gservices上执行目标org.apache.maven.plugins:maven-dependency-plugin:3.1.2:go-offline(default-cli):org.eclipse.aether.resolution.DependencyResolutionException:找不到中央(https://repo.maven.apache.org/maven2)中的工件org.codehaus.groovy:groovy-all:jar:2.5.4

我尝试添加https://dl.bintray.com/groovy/maven/作为附加存储库,但没有帮助。 根据有关依赖的Maven文档:离线:

“此目标与调用mvn依赖项:解决依赖项:解决插件完全相同。”

但是当我运行mvndependency:resolve和mvndependency:resolve-plugins时,它成功了。 我花了很多时间试图解决这个问题。如果有人有想法请分享。

谢谢

1 个答案:

答案 0 :(得分:0)

我在升级 spring-boot-starter-parent 时遇到了完全相同的问题,从 2.2.4 升级到 2.3.8。 就我而言,它包括这个罐子:

<dependency>
     <groupId>org.springframework</groupId>
     <artifactId>spring-test</artifactId>
     <version>5.1.2.RELEASE</version>
     <scope>test</scope>
</dependency>

我的修复相对容易,因为我可以删除这个 jar,因为它实际上并未在项目中使用。 从快速了解您的依赖项来看,这个 jar 似乎是:

<dependency>
    <groupId>org.mnode.ical4j</groupId>
    <artifactId>ical4j</artifactId>
    <version>3.0.14</version>
</dependency>

导入 org.codehaus.groovy jar,这可能是导致您出现问题的原因。