質問編集履歴
3
一部修正
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
Spring Boot エラー: メイン・クラスcom.example.
|
1
|
+
Spring Boot エラー: メイン・クラスcom.example.demo.DemoApplicationを検出およびロードできませんでした
|
body
CHANGED
File without changes
|
2
一部修正
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.
|
10
|
+
<start-class>com.example.demo.DemoApplication</start-class>
|
11
11
|
<java.version>11</java.version>
|
12
12
|
</properties>
|
13
13
|
```
|
1
ソースコード追加
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
|
+
```
|