我按照此處的說明獲取最新spring.framework.boot插件。
我的build.gradle有
plugins {
id 'java-library'
id 'eclipse'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'org.springframework.boot' version '2.6.2'
id 'org.springframework.boot.experimental.thin-launcher' version '1.0.23.RELEASE'
}
但 gradle 任務有錯誤
> Could not resolve all dependencies for configuration ':detachedConfiguration1'.
> Could not find org.springframework.boot:spring-boot-dependencies:2.6.2.
更新我忽略了添加錯誤描述的最后幾行,實際上這對于回答它很重要。
Searched in the following locations:
- https://repo.spring.io/snapshot/org/springframework/boot/spring-boot-dependencies/2.6.2/spring-boot-dependencies-2.6.2.pom
- https://repo.spring.io/milestone/org/springframework/boot/spring-boot-dependencies/2.6.2/spring-boot-dependencies-2.6.2.pom
uj5u.com熱心網友回復:
這是一個完整的檔案作為示例:(這是 ROOT build.gradle)(如果您撰寫單體應用程式,您將只有一個根 build.gradle,如果您撰寫多個“gradle 模塊”,您將有一個root 和子專案 build.gradle 檔案)(如果您不知道我在說什么,請參閱底部的 docs.gradle.org 鏈接)
(您可以洗掉依賴項,但我更愿意提供完整的作業)
plugins {
id 'org.springframework.boot' version '2.6.2'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'java'
}
group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-batch'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-data-ldap'
implementation 'org.springframework.boot:spring-boot-starter-integration'
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'
implementation 'org.springframework.boot:spring-boot-starter-oauth2-resource-server'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-web-services'
implementation 'org.springframework.boot:spring-boot-starter-webflux'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
implementation 'com.h2database:h2'
implementation 'mysql:mysql-connector-java'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'io.projectreactor:reactor-test'
testImplementation 'org.springframework.batch:spring-batch-test'
testImplementation 'org.springframework.integration:spring-integration-test'
testImplementation 'org.springframework.security:spring-security-test'
}
test {
useJUnitPlatform()
}
allprojects {
/* custom task to show dependencies. run "gradle printAllDependencies" from commandline. see https://stackoverflow.com/questions/44266687/how-to-print-out-all-dependencies-in-a-gradle-multi-project-build/54436979#54436979 */
task printAllDependencies(type: DependencyReportTask) {}
}
或者,您可以嘗試“gradle FLUSH”
Gradle FLUSH Cache
(Optional, but preferred). Close all instances of IntelliJ or any other Java IDE.
./gradlew --stop
OR
gradle --stop
(now delete the folders)
rm -rf $HOME/.gradle/caches/
rm -rf $HOME/.gradle/build-cache-tmp/
(now resume normal gradlew commands like:)
./gradlew clean build
或者,你可以做一個 intelliJ "FLUSH"
(tested with IntelliJ version 2020.1 or later)
Close IntelliJ.
Delete the ".idea" folder off of the root folder.
Re OPEN the project.
Wait for Gradle imports and indices rebuild to complete
Try the IDE build again.
And the big hammer: "Invalidate IntelliJ caches". see https://www.jetbrains.com/help/rider/Cleaning_System_Cache.html and/or https://www.jetbrains.com/help/idea/invalidate-caches.html
如果您使用的是 Eclipse 或 NetBeans 或其他,則必須找到“等價物”。這個想法是IDE變得“混亂”。
獎金
多梯度模塊:
https://docs.gradle.org/current/samples/sample_building_java_applications_multi_project.html
uj5u.com熱心網友回復:
感謝上面的@granadaCoder,在將 Gradle 重新安裝到最新版本后7.3.3,實際的問題是第二個存盤庫設定已經潛入我的build.gradle
repositories {
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
}
這正是錯誤說未找到依賴項的地方。我把它改成了
repositories {
mavenCentral()
}
然后事情開始起作用了。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/408788.html
標籤:
