gradlew build でエラー「Could not resolve org.springframework.boot:spring-boot-gradle-plugin:3.2.4. エラー」

実現したいこと

Springプロジェクトを作成し、Herokuにデプロイしようとすると、画面表示する時(heroku open)Application errorが出ており、いろいろと調べていると、Procfileというものを作成しないといけないようです。
そこで、gradlew build && java -jar build/libs/spring-boot-sample-0.1.0.jarを実行すると、エラーが表示されました。

発生している問題・分からないこと

URL「herokuでspring-bootをgradleを使ってデプロイするときのコツ」を参考にしました。
https://qiita.com/gosshys/items/fa02b390b60ee3001dae

プロジェクト直下にbuild.gradleを配置し、コマンドgradlew wrapperを実行すると下記のエラーが表示されました。

特に下記のエラーですが、クラスパスが見つからないということですが、jarファイルなどをどこからかダウンロード、インストールするということでしょうか?

Could not resolve all artifacts for configuration ':classpath'.
Could not resolve org.springframework.boot:spring-boot-gradle-plugin:3.2.4.

エラーメッセージ

error

1C:\spring_workspace\workspace\kintai>gradlew wrapper 2 3FAILURE: Build failed with an exception. 4 5* What went wrong: 6A problem occurred configuring root project 'kintai'. 7> Could not resolve all artifacts for configuration ':classpath'. 8 > Could not resolve org.springframework.boot:spring-boot-gradle-plugin:3.2.4. 9 Required by: 10 project : > org.springframework.boot:org.springframework.boot.gradle.plugin:3.2.4 11 > No matching variant of org.springframework.boot:spring-boot-gradle-plugin:3.2.4 was found. The consumer was configured to find a library for use during runtime, compatible with Java 11, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '8.7' but: 12 - Variant 'apiElements' declares a library, packaged as a jar, and its dependencies declared externally: 13 - Incompatible because this component declares a component for use during compile-time, compatible with Java 17 and the consumer needed a component for use during runtime, compatible with Java 11 14 - Other compatible attribute: 15 - Doesn't say anything about org.gradle.plugin.api-version (required '8.7') 16 - Variant 'javadocElements' declares a component for use during runtime, and its dependencies declared externally: 17 - Incompatible because this component declares documentation and the consumer needed a library 18 - Other compatible attributes: 19 - Doesn't say anything about its elements (required them packaged as a jar) 20 - Doesn't say anything about its target Java version (required compatibility with Java 11) 21 - Doesn't say anything about org.gradle.plugin.api-version (required '8.7') 22 - Variant 'mavenOptionalApiElements' declares a library, packaged as a jar, and its dependencies declared externally: 23 - Incompatible because this component declares a component for use during compile-time, compatible with Java 17 and the consumer needed a component for use during runtime, compatible with Java 11 24 - Other compatible attribute: 25 - Doesn't say anything about org.gradle.plugin.api-version (required '8.7') 26 - Variant 'mavenOptionalRuntimeElements' declares a library for use during runtime, packaged as a jar, and its dependencies declared externally: 27 - Incompatible because this component declares a component, compatible with Java 17 and the consumer needed a component, compatible with Java 11 28 - Other compatible attribute: 29 - Doesn't say anything about org.gradle.plugin.api-version (required '8.7') 30 - Variant 'runtimeElements' declares a library for use during runtime, packaged as a jar, and its dependencies declared externally: 31 - Incompatible because this component declares a component, compatible with Java 17 and the consumer needed a component, compatible with Java 11 32 - Other compatible attribute: 33 - Doesn't say anything about org.gradle.plugin.api-version (required '8.7') 34 - Variant 'sourcesElements' declares a component for use during runtime, and its dependencies declared externally: 35 - Incompatible because this component declares documentation and the consumer needed a library 36 - Other compatible attributes: 37 - Doesn't say anything about its elements (required them packaged as a jar) 38 - Doesn't say anything about its target Java version (required compatibility with Java 11) 39 - Doesn't say anything about org.gradle.plugin.api-version (required '8.7') 40 41* Try: 42> Review the variant matching algorithm at https://docs.gradle.org/8.7/userguide/variant_attributes.html#sec:abm_algorithm. 43> No matching variant errors are explained in more detail at https://docs.gradle.org/8.7/userguide/variant_model.html#sub:variant-no-match. 44> Run with --stacktrace option to get the stack trace. 45> Run with --info or --debug option to get more log output. 46> Run with --scan to get full insights. 47> Get more help at https://help.gradle.org. 48 49BUILD FAILED in 8s

該当のソースコード

build.gradle

1buildscript { 2 repositories { 3 mavenCentral() 4 } 5 dependencies { 6 classpath("org.springframework.boot:spring-boot-gradle-plugin:3.2.4.RELEASE") 7 } 8} 9 10plugins { 11 id 'java' 12 id 'org.springframework.boot' version '3.2.4' 13 id 'io.spring.dependency-management' version '1.1.4' 14} 15 16apply plugin: 'java' 17apply plugin: 'idea' 18apply plugin: 'spring-boot' 19 20jar { 21 baseName = 'spring-boot-sample' 22 version = '0.1.0' 23} 24 25group = 'com.example' 26version = '0.0.1-SNAPSHOT' 27 28java { 29 sourceCompatibility = '21' 30} 31 32configurations { 33 compileOnly { 34 extendsFrom annotationProcessor 35 } 36} 37 38repositories { 39 mavenCentral() 40} 41 42dependencies { 43 implementation 'org.springframework.boot:spring-boot-starter-jdbc' 44 implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' 45 implementation 'org.springframework.boot:spring-boot-starter-web' 46 compileOnly 'org.projectlombok:lombok' 47 developmentOnly 'org.springframework.boot:spring-boot-devtools' 48 runtimeOnly 'org.postgresql:postgresql' 49 annotationProcessor 'org.projectlombok:lombok' 50 testImplementation 'org.springframework.boot:spring-boot-starter-test' 51 implementation 'org.springframework.boot:spring-boot-starter-validation' 52 classpath("org.springframework.boot:spring-boot-gradle-plugin:3.2.4.RELEASE") 53} 54 55tasks.named('test') { 56 useJUnitPlatform() 57} 58

試したこと・調べたこと

上記の詳細・結果

https://qiita.com/gosshys/items/fa02b390b60ee3001dae

https://qiita.com/You_name_is_YU/items/ead77e2e00c120058ce8

結果は同じエラーが表示されます。

補足

OS:Windows10
PG:Java
FW:Spring
DB:Postgresql
デプロイ:Heroku

コメントを投稿

0 コメント