一个简单的 SpringBoot 开发脚手架,记录学习过程和踩的坑。
git clone https://github.com/muxfe/spring-boot-scaffold.git my-project
cd my-project
./gradlew tasks
# run all checks
./gradlew check
# run as spring boot application
SPRING_PROFILES_ACTIVE=development ./gradlew bootRun
Open hal http://localhost:9091/api
in browser.
- Program Arguments:
--spring.profiles.active=development
.
Enable File->Settings->Build,Execution,Deployment->Compiler: Build project automatically
.
Enable File->Settings->Build,Execution,Deployment->Compiler->Annotation Processors: Enable annotation processing
.
GET /api/[repository]
- Accept:
application/json;chartset=utf-8
- Status: 200 Ok
- QueryString
- page(=0)
- size(=20)
- sort(
[property],asc|desc
)
- Response
- _embedded
[entity]
(=[])
- page
- size
- number
- totalElements
- totalPages
- _embedded
- Accept:
GET /api/[repository]/fuzzy
- Accept:
application/json;chartset=utf-8
- Status: 200 Ok
- QueryString
- page(=0)
- size(=20)
- sort(
[property],asc|desc
) - selective
[Entity]
properties(excludeid
)
- Response
- _embedded
[entity]
(=[])
- page
- size
- number
- totalElements
- totalPages
- _embedded
- Accept:
POST /api/[repository]
- ContentType:
application/json
- Accept:
application/json;chartset=utf-8
- Status: 201 Created
- Body
[Entity]
- Response
- new
[Entity]
- new
- ContentType:
PUT /api/[repository]/[id]
- ContentType:
application/json
- Accept:
application/json;chartset=utf-8
- Status: 200 Ok
- Body
- All
[Entity]
properties
- All
- Response
- updated
[Entity]
- updated
- ContentType:
PATCH /api/[repository]/[id]
- ContentType:
application/json
- Accept:
application/json;chartset=utf-8
- Status: 200 Ok
- Body
- Partial
[Entity]
properties
- Partial
- Response
- updated
[Entity]
- updated
- ContentType:
DELETE /api/[repository]/[id]
- Status 204 NoContent
- SpringBootApplication
- Jpa Crud Operation
- Entity and Controller Examples
- Unit Test
-
ExposeIdsRepositoryRestConfiguration
- Support CORS
- Fuzzy search
- Application initializer
- Entity Projection
- https://spring.io/guides/gs/spring-boot/
- https://spring.io/guides/gs/accessing-data-rest/
- https://spring.io/guides/topicals/spring-security-architecture/
- https://spring.io/guides/tutorials/react-and-spring-data-rest/
- https://docs.spring.io/spring-boot/docs/1.5.7.RELEASE/reference/html/
- https://docs.spring.io/spring-security/site/docs/5.0.x/reference/html/