質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Windows 10

Windows 10は、マイクロソフト社がリリースしたOSです。Modern UIを標準画面にした8.1から、10では再びデスクトップ主体に戻され、UIも変更されています。PCやスマホ、タブレットなど様々なデバイスに幅広く対応していることが特徴です。

Javadoc

Javadocは、Java言語で記述されたクラスライブラリ、及びアプリケーションについてのパッケージ・クラス・メソッドのHTML形式のAPI仕様書のことを指します。ドキュメント更新の漏れを減らすことができ、最新の状態を把握することが可能になります。

Visual Studio Code

Visual Studio Codeとは、Microsoft社が開発したマルチプラットフォーム対応のテキストエディタです。Visual Studioファミリーの一員でもあります。拡張性とカスタマイズ性が高く、テキストエディタでありながら、IDEと遜色ない機能を備えることができます。

Spring Boot

Spring Bootは、Javaのフレームワークの一つ。Springプロジェクトが提供する様々なフレームワークを統合した、アプリケーションを高速で開発するために設計されたフレームワークです。

Q&A

解決済

1回答

5391閲覧

mainメソッドのあるファイルを実行してみたが、Main method not foundと表示される。

Ryuu6490

総合スコア9

Windows 10

Windows 10は、マイクロソフト社がリリースしたOSです。Modern UIを標準画面にした8.1から、10では再びデスクトップ主体に戻され、UIも変更されています。PCやスマホ、タブレットなど様々なデバイスに幅広く対応していることが特徴です。

Javadoc

Javadocは、Java言語で記述されたクラスライブラリ、及びアプリケーションについてのパッケージ・クラス・メソッドのHTML形式のAPI仕様書のことを指します。ドキュメント更新の漏れを減らすことができ、最新の状態を把握することが可能になります。

Visual Studio Code

Visual Studio Codeとは、Microsoft社が開発したマルチプラットフォーム対応のテキストエディタです。Visual Studioファミリーの一員でもあります。拡張性とカスタマイズ性が高く、テキストエディタでありながら、IDEと遜色ない機能を備えることができます。

Spring Boot

Spring Bootは、Javaのフレームワークの一つ。Springプロジェクトが提供する様々なフレームワークを統合した、アプリケーションを高速で開発するために設計されたフレームワークです。

0グッド

0クリップ

投稿2022/12/25 12:01

前提

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)

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

自己解決

【自己解決】
workspaceStorageフォルダを削除することで解決しました。

【参考】
https://www.aruse.net/entry/2019/07/28/163927

投稿2022/12/25 12:02

Ryuu6490

総合スコア9

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問