hot*_*oup 8 gradle maven spring-boot
我正在尝试遵循此 Spring Boot/Vaadin 指南 ,但我使用的是 Gradle,而不是Maven。
在该指南的最顶部,他们说使用以下 Maven XML:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-bom</artifactId>
<version>10.0.11</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
Run Code Online (Sandbox Code Playgroud)
但是我没有看到dependencyManagement可以通过 Gradle 执行的任务。所以我问:如何<dependencyManagement/>在“Gradle land”中复制与上面的 XML 元素相同的行为?
dependencyManagement {
imports {
mavenBom 'com.vaadin:vaadin-bom:10.0.11'
}
}
Run Code Online (Sandbox Code Playgroud)
唯一的问题是,当我将其添加到我的build.gradle然后运行时./gradlew clean,我收到以下 Gradle 错误:
“找不到参数的方法 dependencyManagement()... ”
这应该会给你一个工作构建:
\n\nplugins {\n // the Gradle plugin which provides the \xe2\x80\x9cdependencyManagement\xe2\x80\x9d block\n id \'io.spring.dependency-management\' version \'1.0.6.RELEASE\'\n // add Java build functionality to be able to follow the Vaadin guide\n id \'java\'\n}\n\ndependencyManagement {\n imports {\n // the Maven BOM which contains a coherent set of module versions\n // for Vaadin dependencies\n mavenBom \'com.vaadin:vaadin-bom:10.0.11\'\n }\n}\n\nrepositories {\n // find dependency modules on Maven Central\n mavenCentral()\n}\n\ndependencies {\n // the dependency module you need according to the Vaadin with\n // Spring Boot guide; the version of the module is taken from the\n // imported BOM; transitive dependencies are automatically taken\n // care of by Gradle (just as with Maven)\n compile \'com.vaadin:vaadin-spring-boot-starter\'\n}\nRun Code Online (Sandbox Code Playgroud)\n\n运行./gradlew dependencies --configuration compileClasspath以查看所有依赖项现在都在 Java 编译类路径上可用。
编辑以回复评论中的问题:确实,BOM 的导入导致了一组与没有 BOM 时使用的依赖项略有不同的依赖项。您可以像这样看到依赖关系的差异:
\n\n./gradlew dependencies --configuration compileClasspath > with-BOM.txtdependencyManagement块并向单个依赖项添加一个版本:compile \'com.vaadin:vaadin-spring-boot-starter:10.0.11\'./gradlew dependencies --configuration compileClasspath > without-BOM.txtdiff -u with-BOM.txt without-BOM.txt您可以看到细微的差异,例如org.webjars.bowergithub.webcomponents:webcomponentsjs:1.2.6使用 BOM 和1.2.2不使用 BOM 的版本。其原因可以在BOM中找到,其中定义了版本1.2.6,并且作者也提到了其原因:\xe2\x80\x9cTransitive webjar依赖项,在此处定义用于可重复构建\xe2\x80\x9d
| 归档时间: |
|
| 查看次数: |
7824 次 |
| 最近记录: |