“复制Maven”;“依赖管理”;从Gradle内部构建标记
我试图跟随但是我使用的是Gradle,而不是Maven 在该指南的最顶端,他们说要使用以下Maven XML:“复制Maven”;“依赖管理”;从Gradle内部构建标记,maven,spring-boot,gradle,Maven,Spring Boot,Gradle,我试图跟随但是我使用的是Gradle,而不是Maven 在该指南的最顶端,他们说要使用以下Maven XML: <dependencyManagement> <dependencies> <dependency> <groupId>com.vaadin</groupId> <artifactId>vaadin-bom</artifactId>
<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>
唯一的问题是,当我将它添加到我的build.gradle
中,然后运行/gradlew clean
时,我会得到以下gradle错误:
“找不到参数的方法dependencyManagement()。”
这将为您提供一个工作构建:
plugins {
// the Gradle plugin which provides the “dependencyManagement” block
id 'io.spring.dependency-management' version '1.0.6.RELEASE'
// add Java build functionality to be able to follow the Vaadin guide
id 'java'
}
dependencyManagement {
imports {
// the Maven BOM which contains a coherent set of module versions
// for Vaadin dependencies
mavenBom 'com.vaadin:vaadin-bom:10.0.11'
}
}
repositories {
// find dependency modules on Maven Central
mavenCentral()
}
dependencies {
// the dependency module you need according to the Vaadin with
// Spring Boot guide; the version of the module is taken from the
// imported BOM; transitive dependencies are automatically taken
// care of by Gradle (just as with Maven)
compile 'com.vaadin:vaadin-spring-boot-starter'
}
运行/gradlew dependencies--configuration compileClasspath
,查看Java编译类路径上的所有依赖项现在都可用
编辑以回答评论中的问题:事实上,BOM的导入导致的依赖项集与不使用BOM时略有不同。您可以看到依赖关系的不同,如下所示:
/gradlew依赖项--配置compileClasspath>和BOM.txt
dependencyManagement
块并向单个依赖项添加一个版本:编译'com.vaadin:vaadin spring boot starter:10.0.11'
/gradlew依赖项--配置compileClasspath>,不带BOM.txt
diff-u with-BOM.txt而不带BOM.txt
您可以看到一些细微的差异,如与BOM一起使用的
org.webjars.bowergithub.webcomponents:webcomponentsjs:1.2.6
,以及不使用它的版本1.2.2
。原因可以在版本1.2.6
的定义中找到,作者也提到了原因:“可传递的webjar依赖项,在这里为可重复的构建定义”,谢谢@JBNizet(+1)——你能看到我的更新吗?这就是你的想法吗?是的………再次感谢,但Gradle现在抱怨它找不到名为dependencyManagement()
…的方法,因为你没有应用Gradle插件文档中解释的依赖关系管理插件。花点时间阅读此文档。非常棒的答案--谢谢@Chriki(+1)--您的快速问题:确认一下,听起来像是com.vaadin:vaadin-spring-boot-starter
想要引入某些依赖项,但是通过指定mavenBom'com.vaadin:vaadin bom:10.0.11'
我们可以覆盖start默认引入的内容……我理解正确吗?再次感谢!是的,没错。我更新了我的答案,提供了更多的信息。
plugins {
// the Gradle plugin which provides the “dependencyManagement” block
id 'io.spring.dependency-management' version '1.0.6.RELEASE'
// add Java build functionality to be able to follow the Vaadin guide
id 'java'
}
dependencyManagement {
imports {
// the Maven BOM which contains a coherent set of module versions
// for Vaadin dependencies
mavenBom 'com.vaadin:vaadin-bom:10.0.11'
}
}
repositories {
// find dependency modules on Maven Central
mavenCentral()
}
dependencies {
// the dependency module you need according to the Vaadin with
// Spring Boot guide; the version of the module is taken from the
// imported BOM; transitive dependencies are automatically taken
// care of by Gradle (just as with Maven)
compile 'com.vaadin:vaadin-spring-boot-starter'
}