質問編集履歴

2

タイトル、タグを修正

2019/07/05 04:06

投稿

tk_19287
tk_19287

スコア18

test CHANGED
@@ -1 +1 @@
1
- MyBatis連携時に使うDBをH2からMySQLに変更するとエラーになってしまう
1
+ [MyBatis連携]誤ったマッパークラスパスのため、sqlSessionFactory生成エラー
test CHANGED
File without changes

1

タイトルの修正、一部ソースの削除

2019/07/05 04:05

投稿

tk_19287
tk_19287

スコア18

test CHANGED
@@ -1 +1 @@
1
- [Spring Boot]MyBatis連携するのDBをH2からMySQLに変更するとエラー(UnsatisfiedDependencyException)になってしまう
1
+ MyBatis連携使うDBをH2からMySQLに変更するとエラーになってしまう
test CHANGED
@@ -142,9 +142,87 @@
142
142
 
143
143
  Spring Web Starter
144
144
 
145
+
146
+
147
+ **login.html**
148
+
149
+ ```html
150
+
151
+ <body>
152
+
153
+ <h1 th:text="${user}"></h1>
154
+
155
+ <p>テスト</p>
156
+
157
+ </body>
158
+
159
+ ```
160
+
161
+ **schema.sql**
162
+
163
+ ```sql
164
+
165
+ create table user (
166
+
167
+ id int(5) auto_increment,
168
+
169
+ login_id varchar(20) not null,
170
+
171
+ password varchar(20) not null,
172
+
173
+ primary key(id),
174
+
175
+ unique (login_id)
176
+
177
+ ) engine=innodb;
178
+
179
+ ```
180
+
181
+
182
+
183
+ 変更箇所(H2からMySQLにDBを変更)
184
+
185
+ ---
186
+
187
+ **application.property(MySQLのURL等を追加)**
188
+
189
+ ```property
190
+
191
+ mybatis.configuration.map-underscore-to-camel-case=true
192
+
193
+ spring.thymeleaf.mode=HTML
194
+
195
+
196
+
197
+ spring.datasource.url=jdbc:mysql://localhost:3306/test_db
198
+
199
+ spring.datasource.username=root
200
+
201
+ spring.datasource.password=dumy
202
+
203
+ spring.datasource.driver-class-name=com.mysql.jdbc.driver
204
+
205
+
206
+
207
+ ```
208
+
209
+ **pom.xml**
210
+
211
+ 追加(JDBC API,MySQL Driver)※以下のコード
212
+
213
+ 削除(H2 Database)
214
+
145
215
  ```xml
146
216
 
147
- <dependencies>
217
+ <dependency>
218
+
219
+ <groupId>mysql</groupId>
220
+
221
+ <artifactId>mysql-connector-java</artifactId>
222
+
223
+ <scope>runtime</scope>
224
+
225
+ </dependency>
148
226
 
149
227
 
150
228
 
@@ -152,190 +230,10 @@
152
230
 
153
231
  <groupId>org.springframework.boot</groupId>
154
232
 
155
- <artifactId>spring-boot-starter-web</artifactId>
233
+ <artifactId>spring-boot-starter-jdbc</artifactId>
156
234
 
157
235
  </dependency>
158
236
 
159
- <dependency>
160
-
161
- <groupId>org.mybatis.spring.boot</groupId>
162
-
163
- <artifactId>mybatis-spring-boot-starter</artifactId>
164
-
165
- <version>2.0.1</version>
166
-
167
- </dependency>
168
-
169
-
170
-
171
- <dependency>
172
-
173
- <groupId>org.springframework.boot</groupId>
174
-
175
- <artifactId>spring-boot-starter-test</artifactId>
176
-
177
- <scope>test</scope>
178
-
179
- </dependency>
180
-
181
- <dependency>
182
-
183
- <groupId>org.projectlombok</groupId>
184
-
185
- <artifactId>lombok</artifactId>
186
-
187
- </dependency>
188
-
189
-
190
-
191
- <dependency>
192
-
193
- <groupId>org.springframework.boot</groupId>
194
-
195
- <artifactId>spring-boot-starter-freemarker</artifactId>
196
-
197
- </dependency>
198
-
199
- <dependency>
200
-
201
- <groupId>mysql</groupId>
202
-
203
- <artifactId>mysql-connector-java</artifactId>
204
-
205
- <scope>runtime</scope>
206
-
207
- </dependency>
208
-
209
- <dependency>
210
-
211
- <groupId>org.springframework.boot</groupId>
212
-
213
- <artifactId>spring-boot-starter-thymeleaf</artifactId>
214
-
215
- </dependency>
216
-
217
-
218
-
219
- <dependency>
220
-
221
- <groupId>org.springframework.boot</groupId>
222
-
223
- <artifactId>spring-boot-starter-jdbc</artifactId>
224
-
225
- </dependency>
226
-
227
- </dependencies>
228
-
229
-
230
-
231
-
232
-
233
- ```
234
-
235
- **login.html**
236
-
237
- ```html
238
-
239
- <!DOCTYPE html>
240
-
241
- <html xmlns:th="http://www.thymeleaf.org">
242
-
243
- <head>
244
-
245
- <meta charset="UTF-8">
246
-
247
- <title>Test</title>
248
-
249
- </head>
250
-
251
- <body>
252
-
253
- <h1 th:text="${user}"></h1>
254
-
255
- <p>テスト</p>
256
-
257
- </body>
258
-
259
- </html>
260
-
261
- ```
262
-
263
- **schema.sql**
264
-
265
- ```sql
266
-
267
- create table user (
268
-
269
- id int(5) auto_increment,
270
-
271
- login_id varchar(20) not null,
272
-
273
- password varchar(20) not null,
274
-
275
- primary key(id),
276
-
277
- unique (login_id)
278
-
279
- ) engine=innodb;
280
-
281
- ```
282
-
283
-
284
-
285
- 変更箇所(H2からMySQLにDBを変更)
286
-
287
- ---
288
-
289
- **application.property(MySQLのURL等を追加)**
290
-
291
- ```property
292
-
293
- mybatis.configuration.map-underscore-to-camel-case=true
294
-
295
- spring.thymeleaf.mode=HTML
296
-
297
-
298
-
299
- spring.datasource.url=jdbc:mysql://localhost:3306/test_db
300
-
301
- spring.datasource.username=root
302
-
303
- spring.datasource.password=dumy
304
-
305
- spring.datasource.driver-class-name=com.mysql.jdbc.driver
306
-
307
-
308
-
309
- ```
310
-
311
- **pom.xml**
312
-
313
- 追加(JDBC API,MySQL Driver)※以下のコード
314
-
315
- 削除(H2 Database)
316
-
317
- ```xml
318
-
319
- <dependency>
320
-
321
- <groupId>mysql</groupId>
322
-
323
- <artifactId>mysql-connector-java</artifactId>
324
-
325
- <scope>runtime</scope>
326
-
327
- </dependency>
328
-
329
-
330
-
331
- <dependency>
332
-
333
- <groupId>org.springframework.boot</groupId>
334
-
335
- <artifactId>spring-boot-starter-jdbc</artifactId>
336
-
337
- </dependency>
338
-
339
237
  ```
340
238
 
341
239