teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

3

一部修正

2021/01/28 04:46

投稿

tk0506
tk0506

スコア3

title CHANGED
@@ -1,1 +1,1 @@
1
- Spring Boot エラー: メイン・クラスcom.example.Applicationを検出およびロードできませんでした
1
+ Spring Boot エラー: メイン・クラスcom.example.demo.DemoApplicationを検出およびロードできませんでした
body CHANGED
File without changes

2

一部修正

2021/01/28 04:46

投稿

tk0506
tk0506

スコア3

title CHANGED
File without changes
body CHANGED
@@ -7,7 +7,7 @@
7
7
  pom.xml に以下を追加
8
8
  ```
9
9
  <properties>
10
-   <start-class>com.example.Application</start-class>
10
+   <start-class>com.example.demo.DemoApplication</start-class>
11
11
    <java.version>11</java.version>
12
12
  </properties>
13
13
  ```

1

ソースコード追加

2021/01/28 04:45

投稿

tk0506
tk0506

スコア3

title CHANGED
File without changes
body CHANGED
@@ -11,4 +11,44 @@
11
11
    <java.version>11</java.version>
12
12
  </properties>
13
13
  ```
14
- ※Applicationは***Application.javaファイルのclass名
14
+ ※Applicationは***Application.javaファイルのclass名
15
+
16
+
17
+ ### ソースコード
18
+ DemoApplication.java
19
+ ```
20
+ package com.example.demo;
21
+
22
+ import org.springframework.boot.SpringApplication;
23
+ import org.springframework.boot.autoconfigure.SpringBootApplication;
24
+
25
+ @SpringBootApplication
26
+ public class DemoApplication {
27
+
28
+ public static void main(String[] args) {
29
+ SpringApplication.run(DemoApplication.class, args);
30
+ }
31
+
32
+ }
33
+
34
+ ```
35
+ DemoController.java
36
+ ```
37
+ package com.example.demo;
38
+
39
+ import org.springframework.stereotype.Controller;
40
+ import org.springframework.web.bind.annotation.RequestMapping;
41
+
42
+ @Controller
43
+ public class DemoController {
44
+
45
+ @RequestMapping(value="/hello")
46
+ private String hello(){
47
+ return "/index.html";
48
+ }
49
+ }
50
+ ```
51
+ index.html
52
+ ```
53
+ Hello World!
54
+ ```