質問編集履歴

8

誤字

2019/05/18 13:59

投稿

jampack
jampack

スコア10

test CHANGED
File without changes
test CHANGED
@@ -32,7 +32,7 @@
32
32
 
33
33
  ```ここに言語を入力
34
34
 
35
- コード
35
+ 追記4
36
36
 
37
37
  select
38
38
 

7

新情報

2019/05/18 13:59

投稿

jampack
jampack

スコア10

test CHANGED
File without changes
test CHANGED
@@ -30,6 +30,44 @@
30
30
 
31
31
  ```
32
32
 
33
+ ```ここに言語を入力
34
+
35
+ コード
36
+
37
+ select
38
+
39
+ meetingroo0_.room_id as room_id1_0_0_,
40
+
41
+ meetingroo0_.room_name as room_nam2_0_0_
42
+
43
+ from
44
+
45
+ meeting_room meetingroo0_
46
+
47
+ where
48
+
49
+ meetingroo0_.room_id=?
50
+
51
+ 2019-05-18 22:54:10.911 TRACE 5052 --- [nio-8080-exec-1] o.h.type.descriptor.sql.BasicBinder  : binding parameter [1] as [INTEGER] - [7]
52
+
53
+ 2019-05-18 22:54:11.126 ERROR 5052 --- [nio-8080-exec-1] org.thymeleaf.TemplateEngine  : [THYMELEAF][http-nio-8080-exec-1] Exception processing template "rooms/listRooms": Error resolving template [rooms/listRooms], template might not exist or might not be accessible by any of the configured Template Resolvers
54
+
55
+
56
+
57
+ org.thymeleaf.exceptions.TemplateInputException: Error resolving template [rooms/listRooms], template might not exist or might not be accessible by any of the configured Template Resolvers
58
+
59
+
60
+
61
+ 2019-05-18 22:54:11.136 ERROR 5052 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet]  : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.thymeleaf.exceptions.TemplateInputException: Error resolving template [rooms/listRooms], template might not exist or might not be accessible by any of the configured Template Resolvers] with root cause
62
+
63
+
64
+
65
+ org.thymeleaf.exceptions.TemplateInputException: Error resolving template [rooms/listRooms], template might not exist or might not be accessible by any of the configured Template Resolvers
66
+
67
+
68
+
69
+ ```
70
+
33
71
 
34
72
 
35
73
 

6

誤字

2019/05/18 13:58

投稿

jampack
jampack

スコア10

test CHANGED
File without changes
test CHANGED
@@ -148,7 +148,7 @@
148
148
 
149
149
  first_name VARCHAR(255) NOT NULL,
150
150
 
151
- last_nameVARCHAR(255) NOT NULL,
151
+ last_name VARCHAR(255) NOT NULL,
152
152
 
153
153
  password VARCHAR(255) NOT NULL
154
154
 

5

修正

2019/05/18 06:30

投稿

jampack
jampack

スコア10

test CHANGED
File without changes
test CHANGED
@@ -4,332 +4,290 @@
4
4
 
5
5
  ### 発生している問題・エラーメッセージ
6
6
 
7
+
8
+
9
+ ```
10
+
11
+ エラーメッセージ
12
+
13
+
14
+
15
+ org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: missing table [meeting_room]
16
+
17
+
18
+
19
+
20
+
21
+ Caused by: javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: missing table [meeting_room]
22
+
23
+
24
+
25
+ Caused by: org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: missing table [meeting_room]
26
+
27
+
28
+
29
+
30
+
31
+ ```
32
+
33
+
34
+
35
+
36
+
37
+
38
+
39
+ ### 該当のソースコード
40
+
41
+
42
+
43
+ ```ここに言語名を入力
44
+
45
+ package mrs.domain.model;
46
+
47
+ import java.io.Serializable;
48
+
49
+
50
+
51
+ import javax.persistence.Entity;
52
+
53
+ import javax.persistence.GeneratedValue;
54
+
55
+ import javax.persistence.GenerationType;
56
+
57
+ import javax.persistence.Id;
58
+
59
+ @Entity
60
+
61
+ public class MeetingRoom implements Serializable{
62
+
63
+ @Id
64
+
65
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
66
+
67
+ private String roomId;
68
+
69
+
70
+
71
+
72
+
73
+ private String roomName;
74
+
75
+ public String getroomName() {
76
+
77
+ return this.roomName;
78
+
79
+ }
80
+
81
+ public void setroomName(String roomName) {
82
+
83
+ this.roomName=roomName;
84
+
85
+ }
86
+
87
+ }
88
+
89
+
90
+
91
+
92
+
93
+ ```
94
+
95
+ ```
96
+
97
+ DROP TABLE IF EXISTS meeting_room CASCADE;
98
+
99
+ DROP TABLE IF EXISTS reservable_room CASCADE;
100
+
101
+ DROP TABLE IF EXISTS reservation CASCADE;
102
+
103
+ DROP TABLE IF EXISTS usr CASCADE;
104
+
105
+
106
+
107
+ CREATE TABLE IF NOT EXISTS meeting_room(
108
+
109
+ room_id SERIAL NOT NULL,
110
+
111
+ room_name VARCHAR(255) NOT NULL,
112
+
113
+ PRIMARY KEY(room_id)
114
+
115
+ );
116
+
117
+ CREATE TABLE IF NOT EXISTS reservation(
118
+
119
+ reservation_id SERIAL NOT NULL,
120
+
121
+ end_time TIME NOT NULL,
122
+
123
+ start_time TIME NOT NULL,
124
+
125
+ reserved_date DATE NOT NULL,
126
+
127
+ room_id INT4 NOT NULL,
128
+
129
+ user_id VARCHAR(255) NOT NULL,
130
+
131
+ PRIMARY KEY (reservation_id)
132
+
133
+ );
134
+
135
+ CREATE TABLE IF NOT EXISTS reservable_room(
136
+
137
+ reserved_date DATE NOT NULL,
138
+
139
+ room_id INT4 NOT NULL,
140
+
141
+ PRIMARY KEY (reserved_date,room_id)
142
+
143
+ );
144
+
145
+ CREATE TABLE IF NOT EXISTS usr(
146
+
147
+ user_id VARCHAR(255) NOT NULL,
148
+
149
+ first_name VARCHAR(255) NOT NULL,
150
+
151
+ last_nameVARCHAR(255) NOT NULL,
152
+
153
+ password VARCHAR(255) NOT NULL
154
+
155
+ role_name VARCHAR(255) NOT NULL
156
+
157
+ PRIMARY KEY (user_id)
158
+
159
+ );
160
+
161
+
162
+
163
+ ALTER TABLE reservable_room DROP CONSTRAINT IF EXISTS fk_A;
164
+
165
+ ALTER TABLE reservation DROP CONSTRAINT IF EXISTS fk_B;
166
+
167
+ ALTER TABLE reservation DROP CONSTRAINT IF EXISTS fk_C;
168
+
169
+ ALTER TABLE reservable_room ADD CONSTRAINT fk_A FOREIGN KEY (room_id) REFERENCES meeting_room;
170
+
171
+ ALTER TABLE reservation ADD CONSTRAINT fk_B FOREIGN KEY (reserved_date,room_id) REFERENCES reservable_room;
172
+
173
+ ALTER TABLE reservation ADD CONSTRAINT fk_C FOREIGN KEY (user_id) REFERENCES usr;
174
+
175
+ ```
176
+
177
+ ```ここに
178
+
179
+ プロパティ
180
+
181
+ spring.jpa.database=POSTGRESQL
182
+
183
+ spring.datasource.url=jdbc:postgresql://localhost:5432/mrs
184
+
185
+ spring.datasource.username=mrs
186
+
187
+ spring.datasource.password=mrs
188
+
189
+ spring.jpa.hibernate.ddl-auto=validate
190
+
191
+ spring.jpa.properties.hibernate,format_sql=true
192
+
193
+ spring.datasource.sql-script-encoding=UTF-8
194
+
195
+ logging.level.org.hibernate.SQL=DEBUG
196
+
197
+ logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE言語を入力
198
+
199
+
200
+
201
+ ```
202
+
203
+
204
+
7
205
  ```ここに言語を入力
8
206
 
9
- 追記3エラー
10
-
11
- org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: wrong column type encountered in column [reserved_date] in table [reservable_room]; found [date (Types#DATE)], but expecting [timestamp (Types#TIMESTAMP)]
12
-
13
- org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAu
14
-
15
-
16
-
17
-
18
-
19
- Caused by: javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: wrong column type encountered in column [reserved_date] in table [reservable_room]; found [date (Types#DATE)], but expecting [timestamp (Types#TIMESTAMP)]
20
-
21
-
22
-
23
- Caused by: org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: wrong column type encountered in column [reserved_date] in table [reservable_room]; found [date (Types#DATE)], but expecting [timestamp (Types#TIMESTAMP)]
24
-
25
-
26
-
27
-
28
-
29
-
30
-
31
- ```
32
-
33
- ```
34
-
35
- エラーメッセージ
36
-
37
-
38
-
39
- web上でのページ
40
-
41
- Whitelabel Error Page
42
-
43
- This application has no explicit mapping for /error, so you are seeing this as a fallback.
44
-
45
- Thu May 16 22:42:25 JST 2019
46
-
47
- There was an unexpected error (type=Not Found, status=404).
48
-
49
- No message available
207
+ 追記3
208
+
209
+ Controllerクラス
210
+
211
+ package mrs.app.room;
212
+
213
+
214
+
215
+ import java.time.LocalDate;
216
+
217
+ import java.util.List;
218
+
219
+
220
+
221
+ import org.springframework.beans.factory.annotation.Autowired;
222
+
223
+ import org.springframework.format.annotation.DateTimeFormat;
224
+
225
+ import org.springframework.stereotype.Controller;
226
+
227
+ import org.springframework.ui.Model;
228
+
229
+ import org.springframework.web.bind.annotation.PathVariable;
230
+
231
+ import org.springframework.web.bind.annotation.RequestMapping;
232
+
233
+ import org.springframework.web.bind.annotation.RequestMethod;
234
+
235
+
236
+
237
+ import mrs.domain.model.ReservableRoom;
238
+
239
+ import mrs.domain.service.room.RoomService;
240
+
241
+
242
+
243
+ @Controller
244
+
245
+ @RequestMapping("rooms")
246
+
247
+ public class RoomsController {
248
+
249
+ @Autowired
250
+
251
+ RoomService roomService;
252
+
253
+
254
+
255
+ @RequestMapping(method = RequestMethod.GET)
256
+
257
+ String listRooms(Model model) {
258
+
259
+ LocalDate today = LocalDate.now();
260
+
261
+ List<ReservableRoom> rooms = roomService.findReservableRooms(today);
262
+
263
+ model.addAttribute("date",today);
264
+
265
+ model.addAttribute("rooms" , rooms);
266
+
267
+ return "room/listRoom";
268
+
269
+ }
270
+
271
+ @RequestMapping(path = "{date}",method =RequestMethod.GET)
272
+
273
+ String listRooms(
274
+
275
+ @DateTimeFormat(iso = DateTimeFormat.ISO.DATE)@PathVariable("date")LocalDate date, Model model) {
276
+
277
+ List<ReservableRoom>rooms = roomService.findReservableRooms(date);
278
+
279
+ model.addAttribute("rooms",rooms);
280
+
281
+ return "room/ListRooms";
282
+
283
+ }
284
+
285
+ }
50
286
 
51
287
  ```
52
288
 
53
289
  ```ここに言語を入力
54
290
 
55
- 2019-05-16 22:41:18.308  INFO 13868 --- [ main] org.hibernate.type.BasicTypeRegistry  : HHH000270: Type registration [java.util.UUID] overrides previous : org.hibernate.type.UUIDBinaryType@5f254608
56
-
57
- 2019-05-16 22:41:19.524  INFO 13868 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
58
-
59
- 2019-05-16 22:41:20.547  INFO 13868 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
60
-
61
- 2019-05-16 22:41:20.616  WARN 13868 --- [ main] aWebConfiguration$JpaWebMvcConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
62
-
63
- 2019-05-16 22:41:21.019  INFO 13868 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
64
-
65
- 2019-05-16 22:41:21.023  INFO 13868 --- [ main] mrs.MrsApplication  : Started MrsApplication in 6.925 seconds (JVM running for 7.917)
66
-
67
- 2019-05-16 22:42:25.069  INFO 13868 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]  : Initializing Spring DispatcherServlet 'dispatcherServlet'
68
-
69
- 2019-05-16 22:42:25.069  INFO 13868 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet  : Initializing Servlet 'dispatcherServlet'
70
-
71
- 2019-05-16 22:42:25.086  INFO 13868 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet  : Completed initialization in 16 ms
72
-
73
-
74
-
75
- ```
76
-
77
-
78
-
79
-
80
-
81
- ### 該当のソースコード
82
-
83
-
84
-
85
- ```ここに言語名を入力
86
-
87
- package mrs.domain.model;
88
-
89
- import java.io.Serializable;
90
-
91
-
92
-
93
- import javax.persistence.Entity;
94
-
95
- import javax.persistence.GeneratedValue;
96
-
97
- import javax.persistence.GenerationType;
98
-
99
- import javax.persistence.Id;
100
-
101
- @Entity
102
-
103
- public class MeetingRoom implements Serializable{
104
-
105
- @Id
106
-
107
- @GeneratedValue(strategy = GenerationType.IDENTITY)
108
-
109
- private String roomId;
110
-
111
-
112
-
113
-
114
-
115
- private String roomName;
116
-
117
- public String getroomName() {
118
-
119
- return this.roomName;
120
-
121
- }
122
-
123
- public void setroomName(String roomName) {
124
-
125
- this.roomName=roomName;
126
-
127
- }
128
-
129
- }
130
-
131
-
132
-
133
-
134
-
135
- ```
136
-
137
- ```
138
-
139
- DROP TABLE IF EXISTS meeting_room CASCADE;
140
-
141
- DROP TABLE IF EXISTS reservable_room CASCADE;
142
-
143
- DROP TABLE IF EXISTS reservation CASCADE;
144
-
145
- DROP TABLE IF EXISTS usr CASCADE;
146
-
147
-
148
-
149
- CREATE TABLE IF NOT EXISTS meeting_room(
150
-
151
- room_id SERIAL NOT NULL,
152
-
153
- room_name VARCHAR(255) NOT NULL,
154
-
155
- PRIMARY KEY(room_id)
156
-
157
- );
158
-
159
- CREATE TABLE IF NOT EXISTS reservation(
160
-
161
- reservation_id SERIAL NOT NULL,
162
-
163
- end_time TIME NOT NULL,
164
-
165
- start_time TIME NOT NULL,
166
-
167
- reserved_date DATE NOT NULL,
168
-
169
- room_id INT4 NOT NULL,
170
-
171
- user_id VARCHAR(255) NOT NULL,
172
-
173
- PRIMARY KEY (reservation_id)
174
-
175
- );
176
-
177
- CREATE TABLE IF NOT EXISTS reservable_room(
178
-
179
- reserved_date DATE NOT NULL,
180
-
181
- room_id INT4 NOT NULL,
182
-
183
- PRIMARY KEY (reserved_date,room_id)
184
-
185
- );
186
-
187
- CREATE TABLE IF NOT EXISTS usr(
188
-
189
- user_id VARCHAR(255) NOT NULL,
190
-
191
- first_name VARCHAR(255) NOT NULL,
192
-
193
- last_nameVARCHAR(255) NOT NULL,
194
-
195
- password VARCHAR(255) NOT NULL
196
-
197
- role_name VARCHAR(255) NOT NULL
198
-
199
- PRIMARY KEY (user_id)
200
-
201
- );
202
-
203
-
204
-
205
- ALTER TABLE reservable_room DROP CONSTRAINT IF EXISTS fk_A;
206
-
207
- ALTER TABLE reservation DROP CONSTRAINT IF EXISTS fk_B;
208
-
209
- ALTER TABLE reservation DROP CONSTRAINT IF EXISTS fk_C;
210
-
211
- ALTER TABLE reservable_room ADD CONSTRAINT fk_A FOREIGN KEY (room_id) REFERENCES meeting_room;
212
-
213
- ALTER TABLE reservation ADD CONSTRAINT fk_B FOREIGN KEY (reserved_date,room_id) REFERENCES reservable_room;
214
-
215
- ALTER TABLE reservation ADD CONSTRAINT fk_C FOREIGN KEY (user_id) REFERENCES usr;
216
-
217
- ```
218
-
219
- ```ここに
220
-
221
- プロパティ
222
-
223
- spring.jpa.database=POSTGRESQL
224
-
225
- spring.datasource.url=jdbc:postgresql://localhost:5432/mrs
226
-
227
- spring.datasource.username=mrs
228
-
229
- spring.datasource.password=mrs
230
-
231
- spring.jpa.hibernate.ddl-auto=validate
232
-
233
- spring.jpa.properties.hibernate,format_sql=true
234
-
235
- spring.datasource.sql-script-encoding=UTF-8
236
-
237
- logging.level.org.hibernate.SQL=DEBUG
238
-
239
- logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE言語を入力
240
-
241
-
242
-
243
- ```
244
-
245
-
246
-
247
- ```ここに言語を入力
248
-
249
- 追記3
250
-
251
- Controllerクラス
252
-
253
- package mrs.app.room;
254
-
255
-
256
-
257
- import java.time.LocalDate;
258
-
259
- import java.util.List;
260
-
261
-
262
-
263
- import org.springframework.beans.factory.annotation.Autowired;
264
-
265
- import org.springframework.format.annotation.DateTimeFormat;
266
-
267
- import org.springframework.stereotype.Controller;
268
-
269
- import org.springframework.ui.Model;
270
-
271
- import org.springframework.web.bind.annotation.PathVariable;
272
-
273
- import org.springframework.web.bind.annotation.RequestMapping;
274
-
275
- import org.springframework.web.bind.annotation.RequestMethod;
276
-
277
-
278
-
279
- import mrs.domain.model.ReservableRoom;
280
-
281
- import mrs.domain.service.room.RoomService;
282
-
283
-
284
-
285
- @Controller
286
-
287
- @RequestMapping("rooms")
288
-
289
- public class RoomsController {
290
-
291
- @Autowired
292
-
293
- RoomService roomService;
294
-
295
-
296
-
297
- @RequestMapping(method = RequestMethod.GET)
298
-
299
- String listRooms(Model model) {
300
-
301
- LocalDate today = LocalDate.now();
302
-
303
- List<ReservableRoom> rooms = roomService.findReservableRooms(today);
304
-
305
- model.addAttribute("date",today);
306
-
307
- model.addAttribute("rooms" , rooms);
308
-
309
- return "room/listRoom";
310
-
311
- }
312
-
313
- @RequestMapping(path = "{date}",method =RequestMethod.GET)
314
-
315
- String listRooms(
316
-
317
- @DateTimeFormat(iso = DateTimeFormat.ISO.DATE)@PathVariable("date")LocalDate date, Model model) {
318
-
319
- List<ReservableRoom>rooms = roomService.findReservableRooms(date);
320
-
321
- model.addAttribute("rooms",rooms);
322
-
323
- return "room/ListRooms";
324
-
325
- }
326
-
327
- }
328
-
329
- ```
330
-
331
- ```ここに言語を入力
332
-
333
291
  pom.xml
334
292
 
335
293
  <?xml version="1.0" encoding="UTF-8"?>

4

修正

2019/05/17 10:25

投稿

jampack
jampack

スコア10

test CHANGED
File without changes
test CHANGED
@@ -2,17 +2,33 @@
2
2
 
3
3
 
4
4
 
5
-
6
-
7
- 本通りにコードを書いていたのですがWEBページで動作確認しようというところでエラーが発生しました。
8
-
9
- 追記2 WEBページは表示されるようになりましたが新たなエラーメッセージが表示されるようになりました。依然としてテーブルは作成されない模様
10
-
11
- 先ほど気づいたのですが私はeclipseのプラグインとしてSTSをインストールしたのですが本ではSTS単体パッケージでインストールしているようです。なにかヒントになれば幸いです
12
-
13
5
  ### 発生している問題・エラーメッセージ
14
6
 
15
-
7
+ ```ここに言語を入力
8
+
9
+ 追記3エラー
10
+
11
+ org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: wrong column type encountered in column [reserved_date] in table [reservable_room]; found [date (Types#DATE)], but expecting [timestamp (Types#TIMESTAMP)]
12
+
13
+ org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAu
14
+
15
+
16
+
17
+
18
+
19
+ Caused by: javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: wrong column type encountered in column [reserved_date] in table [reservable_room]; found [date (Types#DATE)], but expecting [timestamp (Types#TIMESTAMP)]
20
+
21
+
22
+
23
+ Caused by: org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: wrong column type encountered in column [reserved_date] in table [reservable_room]; found [date (Types#DATE)], but expecting [timestamp (Types#TIMESTAMP)]
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
+ ```
16
32
 
17
33
  ```
18
34
 
@@ -130,7 +146,7 @@
130
146
 
131
147
 
132
148
 
133
- CREATE TABLE IF NOT EXISTS meeting_room{
149
+ CREATE TABLE IF NOT EXISTS meeting_room(
134
150
 
135
151
  room_id SERIAL NOT NULL,
136
152
 
@@ -138,9 +154,9 @@
138
154
 
139
155
  PRIMARY KEY(room_id)
140
156
 
141
- };
157
+ );
142
-
158
+
143
- CREATE TABLE IF NOT EXISTS reservation{
159
+ CREATE TABLE IF NOT EXISTS reservation(
144
160
 
145
161
  reservation_id SERIAL NOT NULL,
146
162
 
@@ -156,9 +172,9 @@
156
172
 
157
173
  PRIMARY KEY (reservation_id)
158
174
 
159
- };
175
+ );
160
-
176
+
161
- CREATE TABLE IF NOT EXISTS reservable_room{
177
+ CREATE TABLE IF NOT EXISTS reservable_room(
162
178
 
163
179
  reserved_date DATE NOT NULL,
164
180
 
@@ -166,9 +182,9 @@
166
182
 
167
183
  PRIMARY KEY (reserved_date,room_id)
168
184
 
169
- };
185
+ );
170
-
186
+
171
- CREATE TABLE IF NOT EXISTS usr{
187
+ CREATE TABLE IF NOT EXISTS usr(
172
188
 
173
189
  user_id VARCHAR(255) NOT NULL,
174
190
 
@@ -182,7 +198,7 @@
182
198
 
183
199
  PRIMARY KEY (user_id)
184
200
 
185
- };
201
+ );
186
202
 
187
203
 
188
204
 
@@ -226,8 +242,94 @@
226
242
 
227
243
  ```
228
244
 
245
+
246
+
229
247
  ```ここに言語を入力
230
248
 
249
+ 追記3
250
+
251
+ Controllerクラス
252
+
253
+ package mrs.app.room;
254
+
255
+
256
+
257
+ import java.time.LocalDate;
258
+
259
+ import java.util.List;
260
+
261
+
262
+
263
+ import org.springframework.beans.factory.annotation.Autowired;
264
+
265
+ import org.springframework.format.annotation.DateTimeFormat;
266
+
267
+ import org.springframework.stereotype.Controller;
268
+
269
+ import org.springframework.ui.Model;
270
+
271
+ import org.springframework.web.bind.annotation.PathVariable;
272
+
273
+ import org.springframework.web.bind.annotation.RequestMapping;
274
+
275
+ import org.springframework.web.bind.annotation.RequestMethod;
276
+
277
+
278
+
279
+ import mrs.domain.model.ReservableRoom;
280
+
281
+ import mrs.domain.service.room.RoomService;
282
+
283
+
284
+
285
+ @Controller
286
+
287
+ @RequestMapping("rooms")
288
+
289
+ public class RoomsController {
290
+
291
+ @Autowired
292
+
293
+ RoomService roomService;
294
+
295
+
296
+
297
+ @RequestMapping(method = RequestMethod.GET)
298
+
299
+ String listRooms(Model model) {
300
+
301
+ LocalDate today = LocalDate.now();
302
+
303
+ List<ReservableRoom> rooms = roomService.findReservableRooms(today);
304
+
305
+ model.addAttribute("date",today);
306
+
307
+ model.addAttribute("rooms" , rooms);
308
+
309
+ return "room/listRoom";
310
+
311
+ }
312
+
313
+ @RequestMapping(path = "{date}",method =RequestMethod.GET)
314
+
315
+ String listRooms(
316
+
317
+ @DateTimeFormat(iso = DateTimeFormat.ISO.DATE)@PathVariable("date")LocalDate date, Model model) {
318
+
319
+ List<ReservableRoom>rooms = roomService.findReservableRooms(date);
320
+
321
+ model.addAttribute("rooms",rooms);
322
+
323
+ return "room/ListRooms";
324
+
325
+ }
326
+
327
+ }
328
+
329
+ ```
330
+
331
+ ```ここに言語を入力
332
+
231
333
  pom.xml
232
334
 
233
335
  <?xml version="1.0" encoding="UTF-8"?>
@@ -358,13 +460,7 @@
358
460
 
359
461
  ### 試したこと
360
462
 
361
- meering_roomが見つからないとのことなのでMeetingRoomクラスに@Table(name=meeting_room)を追加、変わらずエラー
463
+
362
-
363
- 追記MeetingRoomのみの問題か確認するためMeetingRoomをZeetingRoomに名前を変更して再度実行、本来MeetingRoomの下にあったエンティティ(Reservation)がエラーコードのmeeting_roomに置き換わる
364
-
365
- わかったこと
366
-
367
- MeetingRoomに限った話ではなく全体としての問題
368
464
 
369
465
 
370
466
 

3

新たなエラーメッセージ

2019/05/17 08:45

投稿

jampack
jampack

スコア10

test CHANGED
File without changes
test CHANGED
@@ -6,9 +6,9 @@
6
6
 
7
7
  本通りにコードを書いていたのですがWEBページで動作確認しようというところでエラーが発生しました。
8
8
 
9
-
9
+ 追記2 WEBページは表示されるようになりましたが新たなエラーメッセージが表示されるようになりました。依然としてテーブルは作成されない模様
10
+
10
-
11
+ 先ほど気づいたのですが私はeclipseのプラグインとしてSTSをインストールしたのですが本ではSTS単体パッケージでインストールしているようです。なにかヒントになれば幸いです
11
-
12
12
 
13
13
  ### 発生している問題・エラーメッセージ
14
14
 
@@ -18,93 +18,45 @@
18
18
 
19
19
  エラーメッセージ
20
20
 
21
- Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
22
-
23
- 2019-05-14 14:05:12.798 ERROR 17040 --- [ main] o.s.boot.SpringApplication  : Application run failed
24
-
25
-
26
-
27
- org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: missing table [meeting_room]
28
-
29
- at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1778) ~[spring-beans-5.1.6.RELEASE.jar:5.1.6.RELEASE]
30
-
31
- at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:593) ~[spring-beans-5.1.6.RELEASE.jar:5.1.6.RELEASE]
32
-
33
- at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515) ~[spring-beans-5.1.6.RELEASE.jar:5.1.6.RELEASE]
34
-
35
- at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320) ~[spring-beans-5.1.6.RELEASE.jar:5.1.6.RELEASE]
36
-
37
- at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.1.6.RELEASE.jar:5.1.6.RELEASE]
38
-
39
- at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318) ~[spring-beans-5.1.6.RELEASE.jar:5.1.6.RELEASE]
40
-
41
- at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.1.6.RELEASE.jar:5.1.6.RELEASE]
42
-
43
- at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1105) ~[spring-context-5.1.6.RELEASE.jar:5.1.6.RELEASE]
44
-
45
- at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867) ~[spring-context-5.1.6.RELEASE.jar:5.1.6.RELEASE]
46
-
47
- at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549) ~[spring-context-5.1.6.RELEASE.jar:5.1.6.RELEASE]
48
-
49
- at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:142) ~[spring-boot-2.1.4.RELEASE.jar:2.1.4.RELEASE]
50
-
51
- at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775) [spring-boot-2.1.4.RELEASE.jar:2.1.4.RELEASE]
52
-
53
- at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.1.4.RELEASE.jar:2.1.4.RELEASE]
54
-
55
- at org.springframework.boot.SpringApplication.run(SpringApplication.java:316) [spring-boot-2.1.4.RELEASE.jar:2.1.4.RELEASE]
56
-
57
- at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260) [spring-boot-2.1.4.RELEASE.jar:2.1.4.RELEASE]
58
-
59
- at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248) [spring-boot-2.1.4.RELEASE.jar:2.1.4.RELEASE]
60
-
61
- at mrs.MrsApplication.main(MrsApplication.java:10) [classes/:na]
62
-
63
- Caused by: javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: missing table [meeting_room]
64
-
65
- at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:402) ~[spring-orm-5.1.6.RELEASE.jar:5.1.6.RELEASE]
66
-
67
- at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:377) ~[spring-orm-5.1.6.RELEASE.jar:5.1.6.RELEASE]
68
-
69
- at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:341) ~[spring-orm-5.1.6.RELEASE.jar:5.1.6.RELEASE]
70
-
71
- at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1837) ~[spring-beans-5.1.6.RELEASE.jar:5.1.6.RELEASE]
72
-
73
- at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1774) ~[spring-beans-5.1.6.RELEASE.jar:5.1.6.RELEASE]
74
-
75
- ... 16 common frames omitted
76
-
77
- Caused by: org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: missing table [meeting_room]
78
-
79
- at org.hibernate.tool.schema.internal.AbstractSchemaValidator.validateTable(AbstractSchemaValidator.java:121) ~[hibernate-core-5.3.9.Final.jar:5.3.9.Final]
80
-
81
- at org.hibernate.tool.schema.internal.GroupedSchemaValidatorImpl.validateTables(GroupedSchemaValidatorImpl.java:42) ~[hibernate-core-5.3.9.Final.jar:5.3.9.Final]
82
-
83
- at org.hibernate.tool.schema.internal.AbstractSchemaValidator.performValidation(AbstractSchemaValidator.java:89) ~[hibernate-core-5.3.9.Final.jar:5.3.9.Final]
84
-
85
- at org.hibernate.tool.schema.internal.AbstractSchemaValidator.doValidation(AbstractSchemaValidator.java:68) ~[hibernate-core-5.3.9.Final.jar:5.3.9.Final]
86
-
87
- at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:191) ~[hibernate-core-5.3.9.Final.jar:5.3.9.Final]
88
-
89
- at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:72) ~[hibernate-core-5.3.9.Final.jar:5.3.9.Final]
90
-
91
- at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:310) ~[hibernate-core-5.3.9.Final.jar:5.3.9.Final]
92
-
93
- at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:467) ~[hibernate-core-5.3.9.Final.jar:5.3.9.Final]
94
-
95
- at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:939) ~[hibernate-core-5.3.9.Final.jar:5.3.9.Final]
96
-
97
- at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:57) ~[spring-orm-5.1.6.RELEASE.jar:5.1.6.RELEASE]
98
-
99
- at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:365) ~[spring-orm-5.1.6.RELEASE.jar:5.1.6.RELEASE]
100
-
101
- at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:390) ~[spring-orm-5.1.6.RELEASE.jar:5.1.6.RELEASE]
102
-
103
- ... 20 common frames omitted
104
-
105
- ```
106
-
107
-
21
+
22
+
23
+ web上でのページ
24
+
25
+ Whitelabel Error Page
26
+
27
+ This application has no explicit mapping for /error, so you are seeing this as a fallback.
28
+
29
+ Thu May 16 22:42:25 JST 2019
30
+
31
+ There was an unexpected error (type=Not Found, status=404).
32
+
33
+ No message available
34
+
35
+ ```
36
+
37
+ ```ここに言語を入力
38
+
39
+ 2019-05-16 22:41:18.308  INFO 13868 --- [ main] org.hibernate.type.BasicTypeRegistry  : HHH000270: Type registration [java.util.UUID] overrides previous : org.hibernate.type.UUIDBinaryType@5f254608
40
+
41
+ 2019-05-16 22:41:19.524  INFO 13868 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
42
+
43
+ 2019-05-16 22:41:20.547  INFO 13868 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
44
+
45
+ 2019-05-16 22:41:20.616  WARN 13868 --- [ main] aWebConfiguration$JpaWebMvcConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
46
+
47
+ 2019-05-16 22:41:21.019  INFO 13868 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
48
+
49
+ 2019-05-16 22:41:21.023  INFO 13868 --- [ main] mrs.MrsApplication  : Started MrsApplication in 6.925 seconds (JVM running for 7.917)
50
+
51
+ 2019-05-16 22:42:25.069  INFO 13868 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]  : Initializing Spring DispatcherServlet 'dispatcherServlet'
52
+
53
+ 2019-05-16 22:42:25.069  INFO 13868 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet  : Initializing Servlet 'dispatcherServlet'
54
+
55
+ 2019-05-16 22:42:25.086  INFO 13868 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet  : Completed initialization in 16 ms
56
+
57
+
58
+
59
+ ```
108
60
 
109
61
 
110
62
 
@@ -248,6 +200,162 @@
248
200
 
249
201
  ```
250
202
 
203
+ ```ここに
204
+
205
+ プロパティ
206
+
207
+ spring.jpa.database=POSTGRESQL
208
+
209
+ spring.datasource.url=jdbc:postgresql://localhost:5432/mrs
210
+
211
+ spring.datasource.username=mrs
212
+
213
+ spring.datasource.password=mrs
214
+
215
+ spring.jpa.hibernate.ddl-auto=validate
216
+
217
+ spring.jpa.properties.hibernate,format_sql=true
218
+
219
+ spring.datasource.sql-script-encoding=UTF-8
220
+
221
+ logging.level.org.hibernate.SQL=DEBUG
222
+
223
+ logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE言語を入力
224
+
225
+
226
+
227
+ ```
228
+
229
+ ```ここに言語を入力
230
+
231
+ pom.xml
232
+
233
+ <?xml version="1.0" encoding="UTF-8"?>
234
+
235
+ <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
236
+
237
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
238
+
239
+ <modelVersion>4.0.0</modelVersion>
240
+
241
+ <parent>
242
+
243
+ <groupId>org.springframework.boot</groupId>
244
+
245
+ <artifactId>spring-boot-starter-parent</artifactId>
246
+
247
+ <version>2.1.4.RELEASE</version>
248
+
249
+ <relativePath/> <!-- lookup parent from repository -->
250
+
251
+ </parent>
252
+
253
+ <groupId>mrs</groupId>
254
+
255
+ <artifactId>mrs</artifactId>
256
+
257
+ <version>0.0.1-SNAPSHOT</version>
258
+
259
+ <name>mrs</name>
260
+
261
+ <description>Demo project for Spring Boot</description>
262
+
263
+
264
+
265
+ <properties>
266
+
267
+ <java.version>1.8</java.version>
268
+
269
+
270
+
271
+ </properties>
272
+
273
+
274
+
275
+ <dependencies>
276
+
277
+ <dependency>
278
+
279
+ <groupId>org.thymeleaf.extras</groupId>
280
+
281
+ <artifactId>thymeleaf-extras-java8time</artifactId>
282
+
283
+ <version> 3.0.4.RELEASE</version><!--$NO-MVN-MAN-VER$-->
284
+
285
+ </dependency>
286
+
287
+ <dependency>
288
+
289
+ <groupId>org.springframework.boot</groupId>
290
+
291
+ <artifactId>spring-boot-starter-thymeleaf</artifactId>
292
+
293
+ </dependency>
294
+
295
+
296
+
297
+ <dependency>
298
+
299
+ <groupId>org.springframework.boot</groupId>
300
+
301
+ <artifactId>spring-boot-starter-data-jpa</artifactId>
302
+
303
+ </dependency>
304
+
305
+ <dependency>
306
+
307
+ <groupId>org.springframework.boot</groupId>
308
+
309
+ <artifactId>spring-boot-starter-web</artifactId>
310
+
311
+ </dependency>
312
+
313
+
314
+
315
+ <dependency>
316
+
317
+ <groupId>org.postgresql</groupId>
318
+
319
+ <artifactId>postgresql</artifactId>
320
+
321
+ <scope>runtime</scope>
322
+
323
+ </dependency>
324
+
325
+ <dependency>
326
+
327
+ <groupId>org.springframework.boot</groupId>
328
+
329
+ <artifactId>spring-boot-starter-test</artifactId>
330
+
331
+ <scope>test</scope>
332
+
333
+ </dependency>
334
+
335
+ </dependencies>
336
+
337
+
338
+
339
+ <build>
340
+
341
+ <plugins>
342
+
343
+ <plugin>
344
+
345
+ <groupId>org.springframework.boot</groupId>
346
+
347
+ <artifactId>spring-boot-maven-plugin</artifactId>
348
+
349
+ </plugin>
350
+
351
+ </plugins>
352
+
353
+ </build>
354
+
355
+ </project>
356
+
357
+ ```
358
+
251
359
  ### 試したこと
252
360
 
253
361
  meering_roomが見つからないとのことなのでMeetingRoomクラスに@Table(name=meeting_room)を追加、変わらずエラー

2

追加情報

2019/05/16 14:02

投稿

jampack
jampack

スコア10

test CHANGED
File without changes
test CHANGED
@@ -8,6 +8,8 @@
8
8
 
9
9
 
10
10
 
11
+
12
+
11
13
  ### 発生している問題・エラーメッセージ
12
14
 
13
15
 
@@ -250,6 +252,12 @@
250
252
 
251
253
  meering_roomが見つからないとのことなのでMeetingRoomクラスに@Table(name=meeting_room)を追加、変わらずエラー
252
254
 
255
+ 追記MeetingRoomのみの問題か確認するためMeetingRoomをZeetingRoomに名前を変更して再度実行、本来MeetingRoomの下にあったエンティティ(Reservation)がエラーコードのmeeting_roomに置き換わる
256
+
257
+ わかったこと
258
+
259
+ MeetingRoomに限った話ではなく全体としての問題
260
+
253
261
 
254
262
 
255
263
 

1

エラーメッセージをブロック内にいれた

2019/05/15 07:02

投稿

jampack
jampack

スコア10

test CHANGED
File without changes
test CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
 
4
4
 
5
- ここに質問の内容を詳しく書いてください。
5
+
6
6
 
7
7
  本通りにコードを書いていたのですがWEBページで動作確認しようというところでエラーが発生しました。
8
8
 
@@ -16,8 +16,6 @@
16
16
 
17
17
  エラーメッセージ
18
18
 
19
- ```
20
-
21
19
  Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
22
20
 
23
21
  2019-05-14 14:05:12.798 ERROR 17040 --- [ main] o.s.boot.SpringApplication  : Application run failed
@@ -102,6 +100,10 @@
102
100
 
103
101
  ... 20 common frames omitted
104
102
 
103
+ ```
104
+
105
+
106
+
105
107
 
106
108
 
107
109