> For the complete documentation index, see [llms.txt](https://cxz.gitbook.io/spring-cloud-date-flow/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cxz.gitbook.io/spring-cloud-date-flow/configuration/maven.md).

# Maven

### 配置方式

在配置中如果需要使用特定的Maven配置属性（maven私服，代理或者其他）或者运行一个需要代理的Data Flow 服务，你需要在启动服务的时候配置对应属性作为启动命令，如下：

```bash
$ java -jar spring-cloud-dataflow-server-2.1.0.RELEASE.jar \
       --spring.config.additional-location=/home/joe/maven.yml &
```

其中maven.yaml的配置是

```yaml
maven:
  localRepository: mylocal
  remote-repositories:
    repo1:
      url: https://repo1
      auth:
        username: user1
        password: pass1
      snapshot-policy:
        update-policy: daily
        checksum-policy: warn
      release-policy:
        update-policy: never
        checksum-policy: fail
    repo2:
      url: https://repo2
      policy:
        update-policy: always
        checksum-policy: fail
  proxy:
    host: proxy1
    port: "9010"
    auth:
      username: proxyuser1
      password: proxypass1
```

通常情况下，协议默认使用 http 。如果代理配置不需要使用用户名和密码，可以忽略auth配置。Maven 默认的 `localRepository`设置为`${user.home}/.m2/repository/`。如以上配置所示，可以指定远程的maven库以及私服并且配置对应的身份验证。如果远程库需要使用代理，可以按照以上模版进行配置。

可以为每一远程存储库配置不同的策略模式，如上例所示。`policy` 配置了 `snapshot`和`release` 的存储策略。

&#x20;您可以参考[存储库策略](https://github.com/eclipse/aether-core/blob/4cf5f7a406b516a45d8bf15e7dfe3fb3849cb87b/aether-api/src/main/java/org/eclipse/aether/repository/RepositoryPolicy.java#L16)以获取支持的存储库策略列表。

这些配置是Spring Boot `@ConfigurationProperties` 的启动配置，你可以将它们添加到`SPRING_APPLICATION_JSON` 中，如下：

```bash
$ 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" } } } }' java -jar spring-cloud-dataflow-server-2.1.0.RELEASE.jar
```
