実現したいこと
Springプロジェクトを作成し、Herokuにデプロイしましたがエラーが出ています。
発生している問題・分からないこと
デプロイした時にエラーが発生します。( > Could not resolve all artifacts for configuration ':classpath'.・・・)
エラーの原因として予想は、下記の問題なのかと思うのですが、解決できません。
・おそらくgradleのバージョンとSpring もしくはJavaのバージョンが合ってない?
・build.gradleの設定ができていない。
エラーメッセージ
error
1-----> Building on the Heroku-22 stack 2-----> Determining which buildpack to use for this app 3-----> Gradle app detected 4-----> Spring Boot detected 5-----> Installing OpenJDK 1.8... done 6-----> Building Gradle app... 7-----> executing ./gradlew build -x check 8 Downloading https://services.gradle.org/distributions/gradle-8.7-bin.zip 9 ............10%.............20%.............30%.............40%............50%.............60%.............70%.............80%.............90%............100% 10 To honour the JVM settings for this build a single-use Daemon process will be forked. For more on this, please refer to https://docs.gradle.org/8.7/userguide/gradle_daemon.html#sec:disabling_the_daemon in the Gradle documentation. 11 Daemon will be stopped at the end of the build 12 13 FAILURE: Build failed with an exception. 14 15 * What went wrong: 16 A problem occurred configuring root project 'kintai'. 17 > Could not resolve all artifacts for configuration ':classpath'. 18 > Could not resolve org.springframework.boot:spring-boot-gradle-plugin:3.2.4. 19 Required by: 20 project : > org.springframework.boot:org.springframework.boot.gradle.plugin:3.2.4 21 > 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 8, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '8.7' but: 22 - Variant 'apiElements' 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 8 24 - Other compatible attribute: 25 - Doesn't say anything about org.gradle.plugin.api-version (required '8.7') 26 - Variant 'javadocElements' declares a component for use during runtime, and its dependencies declared externally: 27 - Incompatible because this component declares documentation and the consumer needed a library 28 - Other compatible attributes: 29 - Doesn't say anything about its elements (required them packaged as a jar) 30 - Doesn't say anything about its target Java version (required compatibility with Java 8) 31 - Doesn't say anything about org.gradle.plugin.api-version (required '8.7') 32 - Variant 'mavenOptionalApiElements' declares a library, packaged as a jar, and its dependencies declared externally: 33 - 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 8 34 - Other compatible attribute: 35 - Doesn't say anything about org.gradle.plugin.api-version (required '8.7') 36 - Variant 'mavenOptionalRuntimeElements' declares a library for use during runtime, packaged as a jar, and its dependencies declared externally: 37 - Incompatible because this component declares a component, compatible with Java 17 and the consumer needed a component, compatible with Java 8 38 - Other compatible attribute: 39 - Doesn't say anything about org.gradle.plugin.api-version (required '8.7') 40 - Variant 'runtimeElements' declares a library for use during runtime, packaged as a jar, and its dependencies declared externally: 41 - Incompatible because this component declares a component, compatible with Java 17 and the consumer needed a component, compatible with Java 8 42 - Other compatible attribute: 43 - Doesn't say anything about org.gradle.plugin.api-version (required '8.7') 44 - Variant 'sourcesElements' declares a component for use during runtime, and its dependencies declared externally: 45 - Incompatible because this component declares documentation and the consumer needed a library 46 - Other compatible attributes: 47 - Doesn't say anything about its elements (required them packaged as a jar) 48 - Doesn't say anything about its target Java version (required compatibility with Java 8) 49 - Doesn't say anything about org.gradle.plugin.api-version (required '8.7') 50 51 * Try: 52 > Review the variant matching algorithm at https://docs.gradle.org/8.7/userguide/variant_attributes.html#sec:abm_algorithm. 53 > No matching variant errors are explained in more detail at https://docs.gradle.org/8.7/userguide/variant_model.html#sub:variant-no-match. 54 > Run with --stacktrace option to get the stack trace. 55 > Run with --info or --debug option to get more log output. 56 > Run with --scan to get full insights. 57 > Get more help at https://help.gradle.org. 58 59 BUILD FAILED in 10s 60 ! ERROR: Failed to run Gradle! 61 We're sorry this build is failing. If you can't find the issue in application 62 code, please submit a ticket so we can help: https://help.heroku.com 63 You can also try reverting to the previous version of the buildpack by running: 64 $ heroku buildpacks:set https://github.com/heroku/heroku-buildpack-gradle#previous-version 65 66 Thanks, 67 Heroku 68 ! Push rejected, failed to compile Gradle app. 69 ! Push failed
該当のソースコード
build.gradle
1plugins { 2 id 'java' 3 id 'org.springframework.boot' version '3.2.4' 4 id 'io.spring.dependency-management' version '1.1.4' 5} 6 7group = 'com.example' 8version = '0.0.1-SNAPSHOT' 9 10java { 11 sourceCompatibility = '21' 12} 13 14configurations { 15 compileOnly { 16 extendsFrom annotationProcessor 17 } 18} 19 20repositories { 21 mavenCentral() 22} 23 24dependencies { 25 implementation 'org.springframework.boot:spring-boot-starter-jdbc' 26 implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' 27 implementation 'org.springframework.boot:spring-boot-starter-web' 28 compileOnly 'org.projectlombok:lombok' 29 developmentOnly 'org.springframework.boot:spring-boot-devtools' 30 runtimeOnly 'org.postgresql:postgresql' 31 annotationProcessor 'org.projectlombok:lombok' 32 testImplementation 'org.springframework.boot:spring-boot-starter-test' 33 implementation 'org.springframework.boot:spring-boot-starter-validation' 34 classpath 'org.springframework.boot:spring-boot-gradle-plugin:3.2.4.RELEASE' 35} 36 37tasks.named('test') { 38 useJUnitPlatform() 39} 40
試したこと・調べたこと
- teratailやGoogle等で検索した
- ソースコードを自分なりに変更した
- 知人に聞いた
- その他
上記の詳細・結果
下記のURLを参考にしました。
https://shinsuke789.hatenablog.jp/entry/2018/09/25/110000
補足
<開発環境>
PG:Java17.0.11
FW:Spring3.2.4(gradle8.7)
DB:postgresql12.18
IDE:eclipse2023-12 (4.30.0)
回答1件
あなたの回答
tips
プレビュー