企业🤖AI Agent构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
### 59.1.5 自定义依赖管理 默认情况下,CLI使用在解析`@Grab`依赖时`spring-boot-dependencies`声明的依赖管理,其他的依赖管理会覆盖默认的依赖管理,并可以通过`@DependencyManagementBom`注解进行配置。该注解的值必须是一个或多个Maven BOMs的候选(`groupId:artifactId:version`)。 例如,以下声明: ```grovy @DependencyManagementBom("com.example.custom-bom:1.0.0") ``` 将选择Maven仓库中`com/example/custom-versions/1.0.0/`下的`custom-bom-1.0.0.pom`。 当指定多个BOMs时,它们会以声明次序进行应用,例如: ```grovy @DependencyManagementBom(["com.example.custom-bom:1.0.0", "com.example.another-bom:1.0.0"]) ``` 意味着`another-bom`的依赖将覆盖`custom-bom`依赖。 能够使用`@Grab`的地方,你同样可以使用`@DependencyManagementBom`。然而,为了确保依赖管理的一致次序,你在应用中至多使用一次`@DependencyManagementBom`。[Spring IO Platform](http://platform.spring.io/)是一个非常有用的依赖元数据源(Spring Boot的超集),例如: `@DependencyManagementBom('io.spring.platform:platform-bom:1.1.2.RELEASE')`。