前提
mainメソッドのあるファイルを実行してみたが、Main method not foundと表示され、SpringBootアプリケーションを起動実行できない。
実現したいこと
SpringBootアプリケーションを起動実行させたい。
発生している問題・エラーメッセージ
vscodeのエラーメッセージ
1Main method not found in the file, please define the main method as: public static void main(String[] args)
vscodeの問題欄
1The supplied phased action failed with an exception. 2A problem occurred configuring root project 'chat-backend'. 3Could not resolve all files for configuration ':classpath'. 4Could not resolve org.springframework.boot:spring-boot-gradle-plugin:3.0.1. 5Required by: 6 project : > org.springframework.boot:org.springframework.boot.gradle.plugin:3.0.1 7No matching variant of org.springframework.boot:spring-boot-gradle-plugin:3.0.1 was found. The consumer was configured to find a runtime of a library compatible with Java 11, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '7.6' but: 8 - Variant 'apiElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.0.1 declares a library, packaged as a jar, and its dependencies declared externally: 9 - Incompatible because this component declares an API of a component compatible with Java 17 and the consumer needed a runtime of a component compatible with Java 11 10 - Other compatible attribute: 11 - Doesn't say anything about org.gradle.plugin.api-version (required '7.6') 12 - Variant 'javadocElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.0.1 declares a runtime of a component, and its dependencies declared externally: 13 - Incompatible because this component declares documentation and the consumer needed a library 14 - Other compatible attributes: 15 - Doesn't say anything about its target Java version (required compatibility with Java 11) 16 - Doesn't say anything about its elements (required them packaged as a jar) 17 - Doesn't say anything about org.gradle.plugin.api-version (required '7.6') 18 - Variant 'mavenOptionalApiElements' capability org.springframework.boot:spring-boot-gradle-plugin-maven-optional:3.0.1 declares a library, packaged as a jar, and its dependencies declared externally: 19 - Incompatible because this component declares an API of a component compatible with Java 17 and the consumer needed a runtime of a component compatible with Java 11 20 - Other compatible attribute: 21 - Doesn't say anything about org.gradle.plugin.api-version (required '7.6') 22 - Variant 'mavenOptionalRuntimeElements' capability org.springframework.boot:spring-boot-gradle-plugin-maven-optional:3.0.1 declares a runtime of a library, packaged as a jar, and its dependencies declared externally: 23 - Incompatible because this component declares a component compatible with Java 17 and the consumer needed a component compatible with Java 11 24 - Other compatible attribute: 25 - Doesn't say anything about org.gradle.plugin.api-version (required '7.6') 26 - Variant 'runtimeElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.0.1 declares a runtime of a library, 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 '7.6') 30 - Variant 'sourcesElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.0.1 declares a runtime of a component, and its dependencies declared externally: 31 - Incompatible because this component declares documentation and the consumer needed a library 32 - Other compatible attributes: 33 - Doesn't say anything about its target Java version (required compatibility with Java 11) 34 - Doesn't say anything about its elements (required them packaged as a jar) 35 - Doesn't say anything about org.gradle.plugin.api-version (required '7.6')
該当のソースコード
ChatBackendApplication.java
1package com.kenji.techpit.chat.chatbackend; 2 3import org.springframework.boot.SpringApplication; 4import org.springframework.boot.autoconfigure.SpringBootApplication; 5 6@SpringBootApplication 7public class ChatBackendApplication { 8 public static void main(String[] args) { 9 SpringApplication.run(ChatBackendApplication.class, args); 10 } 11} 12
試したこと
・クラス名とファイル名が一致しているかどうか確認。
補足情報(FW/ツールのバージョンなど)
Windows10 64bit
Visual Studio Code 1.74.2
openjdk version "11" 2018-09-25
OpenJDK Runtime Environment 18.9 (build 11+28)
OpenJDK 64-Bit Server VM 18.9 (build 11+28, mixed mode)
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。