Rate This Document
Findability
Accuracy
Completeness
Readability

spring-cloud-function Dependency Pulling Failure

Symptom

If the compilation environment requires a proxy for connecting to the Internet, dependencies may fail to be pulled.

Key Process and Cause Analysis

The compilation environment needs to access the Internet through a proxy.

Conclusion and Solution

You can configure a proxy, or replace the Maven repository with the Huawei Maven repository to solve the problem.

Method 1: Configuring a Proxy

  1. Open the DependencyResolver.java file.
    vim ./spring-cloud-function-compiler/src/main/java/org/springframework/cloud/function/compiler/java/DependencyResolver.java
  2. Modify the following code. Save the file and exit.
    • Add the following content below line 81:
      import org.eclipse.aether.repository.Proxy;

    • Modify line 280 as follows:
      .setReleasePolicy(policy(input.getReleases()))
    • Add the following content to line 281:
      .setProxy(new Proxy("https","127.0.0.1",3128)).build();

      In the preceding example, 127.0.0.1 and 3128 indicate the IP address and port number of the proxy host. Replace them with the actual ones.

  3. Press Esc, type :wq!, and press Enter to save the file and exit.
  4. Open the RuntimeJavaCompilerTests.java file.
    vim ./spring-cloud-function-compiler/src/test/java/org/springframework/cloud/function/compiler/java/RuntimeJavaCompilerTests.java
  5. In line 142, change find to transfer.

  6. Press Esc, type :wq!, and press Enter to save the file and exit.
  7. Run the compile command again.
    ./mvnw clean install -Dgpg.skip=true

Method 2: Replacing the Maven Repository with the Huawei Maven Repository

  1. Open the DependencyResolver.java file.
    vim ./spring-cloud-function-compiler/src/main/java/org/springframework/cloud/function/compiler/java/DependencyResolver.java
  2. Change the Maven repository to Huawei Kunpeng Maven.

  3. Add the IP address of the Huawei Kunpeng Maven repository to /etc/hosts.
    1
    2
    echo 172.30.163.193 mirrors.huaweicloud.com >> /etc/hosts
    cat /etc/hosts
    
  4. Add a proxy for the spring-cloud-function-deployer module.
    vim spring-cloud-function-deployer/src/it/settings.xml

    Change the values of username, password, host and port as required.

  5. Run the compile command again.
    ./mvnw clean install -Dgpg.skip=true