用Spring Boot构建Rest API
概述
-
- 手探りで Spring Boot を勉強しながら Rest API を構築していく
- Qiita にはやった分だけ投稿していく
新建项目

Spring Initializr 春季初始器
项目SDK版本:1.8
选择Initializr服务URL:默认(https://start.spring.io)
项目元数据
组织:com.example
组件:spring-boot-rest-api
类型:Gradle项目(生成一个基于Gradle的项目档案)
语言:Java
打包:Jar
Java版本:8
版本:0.0.1-SNAPSHOT
名称:spring-boot-rest-api
描述:Spring Boot的演示项目
包:com.example.springbootrestapi
依赖关系
开发者工具: Spring Boot DevTools, Lombok
Web: Spring Web Starter
SQL: Spring Data JPA, MySQL Driver
项目设置
項目名稱:春季啟動Rest API
項目位置:適宜
从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 可以在应用程序.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 の設計を行う