java - Gradle 子项目依赖项不起作用,但相同的依赖项在主 gradle 中工作正常
问题描述
我一直在为 spring boot devtools 开发多模块 gradle 项目。这是 github 存储库 - GitHub 存储库
-spring-boot-dev-tools
-src/main
-java/com/jhooq/springboot/devtools
-resources
-spring-boot-dev-tools.gradle ====- subproject gradle
-.gitignore
-build.gradle ====- main gradle
-gradlew
-gradlew.bat
-settings.gradle
这就是我的 build.gradle(main gradle) 的样子: -
buildscript {
ext {
springBootVersion = '2.1.2.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
allprojects {
group 'com.jhooq'
version '1.0-SNAPSHOT'
}
subprojects{
repositories {
mavenCentral()
}
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
sourceCompatibility = 1.8
targetCompatibility = 1.8
dependencies {
compile ("org.springframework.boot:spring-boot-starter")
compile ("org.springframework.boot:spring-boot-starter-test")
}
}
project(':spring-boot-dev-tools'){
configurations {
developmentOnly
runtimeClasspath {
extendsFrom developmentOnly
}
}
dependencies {
compile project(':spring-boot-app')
compile ("org.springframework.boot:spring-boot-starter-web")
developmentOnly("org.springframework.boot:spring-boot-devtools")
}
}
因此,您可以看到我是否将我的 Spring Boot 应用程序放入端口 8000 并继续compile ("org.springframework.boot:spring-boot-starter-web")
运行project(':spring-boot-dev-tools')
但是当我在里面移动以下 gradle 脚本时遇到问题spring-boot-dev-tools.gradle
,然后我的 spring boot 应用程序就像普通的 spring boot 应用程序一样启动和关闭。
project(':spring-boot-dev-tools'){
configurations {
developmentOnly
runtimeClasspath {
extendsFrom developmentOnly
}
}
dependencies {
compile project(':spring-boot-app')
compile ("org.springframework.boot:spring-boot-starter-web")
developmentOnly("org.springframework.boot:spring-boot-devtools")
}
spring-boot-starter-web
因此,如果我在子模块中移动 spring和 依赖项时总结了我的问题spring-boot-devtools
,spring boot 在端口:8000 上不起作用/运行,而是像普通的 spring boot 应用程序一样启动和关闭。
解决方案
推荐阅读
- java - 确定字符串中字母顺序的代码——返回变量初始化错误
- javascript - 当我只上传一次时,图像在表格中插入了两次
- javascript - 动态附加的文本字段值未通过 javascript 中的 id 打印
- ag-grid - 使用 forEachNode 的行选择非常慢
- python - 将抓取的表存储为字典并输出为 pandas DataFrame
- android - 如何在 Android Studio 中更改默认语言(国际而非编程)
- google-apps-script - 绘制边框脚本的应用不一致
- java - Mono.subscriberContext() 返回旧上下文
- vba - 如何使用 VBA 将滞后添加到 MS Project 中的前置字段
- c# - 未处理的异常:System.BadImageFormatException:无法加载从 RoslynCompileSample 加载的文件或程序集 '0 字节,