Outline
- 手探りで Spring Boot を勉強しながら Rest API を構築していく
- Qiita にはやった分だけ投稿していく
Create New Project
IntelliJ の Spring Initializr を使う
Spring Initializr
Project SDK: 1.8
Choose Initializr Service URL: Default (https://start.spring.io)
Project Metadata
Group: com.example
Artifact: spring-boot-rest-api
Type: Gradle Project (Generate a Gradle based project archive)
Language: Java
Packaging: Jar
Java Version: 8
Version: 0.0.1-SNAPSHOT
NAME: spring-boot-rest-api
Description: Demo project for Spring Boot
Package: com.example.springbootrestapi
Dependencies
Developer Tools: Spring Boot DevTools, Lombok
Web: Spring Web Starter
SQL: Spring Data JPA, MySQL Driver
Project Settings
Project name: spring-boot-rest-api
Project location: 適宜
Import Module from Gradle
一旦デフォルト設定のまま
OKでプロジェクト作成が完了
IntelliJ で Lombok 有効化
こちらを参照
https://reasonable-code.com/intellij-lombok/
設定ファイルを yml に変更
spring-boot-rest-api/src/main/resources/application.properties
リネームする
spring-boot-rest-api/src/main/resources/application.yml
とりあえず起動してみる
エラーになった
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-08-17 23:19:54.141 ERROR 29198 --- [ restartedMain] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
Reason: Failed to determine a suitable driver class
Action:
Consider the following:
If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).
Process finished with exit code 0
続きの予告
- エラーの調査
- Docker で MySQL 構築
- Swagger を使って API の設計を行う