33. Configure Remote Maven Repository

If you’d like to connect to your organization’s internal maven repository, you can override the default repository location by passing the credentials via the following environment properties:

export MAVEN_LOCAL_REPOSITORY=mylocalMavenRepo
export MAVEN_REMOTE_REPOSITORIES_REPO1_URL=https://repo1
export MAVEN_REMOTE_REPOSITORIES_REPO1_AUTH_USERNAME=user1
export MAVEN_REMOTE_REPOSITORIES_REPO1_AUTH_PASSWORD=pass1
export MAVEN_REMOTE_REPOSITORIES_REPO2_URL=https://repo2

If you are running behind a proxy, then you need to specify the proxy settings via environment properties like this:

export MAVEN_PROXY_PROTOCOL=https
export MAVEN_PROXY_HOST=host1
export MAVEN_PROXY_PORT=8090
export MAVEN_PROXY_NON_PROXY_HOSTS='host2|host3'
export MAVEN_PROXY_AUTH_USERNAME=user1
export MAVEN_PROXY_AUTH_PASSWORD=passwd

Alternatively, you can pass them wrapped inside SPRING_APPLICATION_JSON environment property like the following:

export SPRING_APPLICATION_JSON='{ "maven": { "local-repository": null,"remote-repositories": { "repo1": { "url": "https://repo1", "auth": { "username": "repo1user", "password": "repo1pass" } }, "repo2": { "url": "https://repo2" } }, "proxy": { "host": "proxyhost", "port": 9018, "auth": { "username": "proxyuser", "password": "proxypass" } } } }'

Formatted JSON:

SPRING_APPLICATION_JSON='{
  "maven": {
    "local-repository": null,
    "remote-repositories": {
      "repo1": {
        "url": "https://repo1",
        "auth": {
          "username": "repo1user",
          "password": "repo1pass"
        }
      },
      "repo2": {
        "url": "https://repo2"
      }
    },
    "proxy": {
      "host": "proxyhost",
      "port": 9018,
      "auth": {
        "username": "proxyuser",
        "password": "proxypass"
      }
    }
  }
}'
[Note]Note

Depending on Spring Cloud Data Flow’s server implementation, you may have to pass the environment properties using the platform specific environment-setting capabilities. For instance, in Cloud Foundry, you’d be passing them as cf set-env SPRING_APPLICATION_JSON, cf set-env MAVEN_REMOTE_REPOSITORIES_REPO1_URL etc.