spring-boot-realworld-examp.../README.md

70 lines
2.7 KiB
Markdown
Raw Permalink Normal View History

2017-08-18 16:40:21 +07:00
# ![RealWorld Example App using Kotlin and Spring](example-logo.png)
2020-11-26 15:05:49 +07:00
[![Actions](https://github.com/gothinkster/spring-boot-realworld-example-app/workflows/Java%20CI/badge.svg)](https://github.com/gothinkster/spring-boot-realworld-example-app/actions)
2017-08-18 16:40:21 +07:00
> ### Spring boot + MyBatis codebase containing real world examples (CRUD, auth, advanced patterns, etc) that adheres to the [RealWorld](https://github.com/gothinkster/realworld-example-apps) spec and API.
This codebase was created to demonstrate a fully fledged fullstack application built with Spring boot + Mybatis including CRUD operations, authentication, routing, pagination, and more.
For more information on how to this works with other frontends/backends, head over to the [RealWorld](https://github.com/gothinkster/realworld) repo.
# How it works
The application uses Spring boot (Web, Mybatis).
2017-08-18 17:51:34 +07:00
* Use the idea of Domain Driven Design to separate the business term and infrastruture term.
* Use MyBatis to implement the [Data Mapper](https://martinfowler.com/eaaCatalog/dataMapper.html) pattern for persistence.
* Use [CQRS](https://martinfowler.com/bliki/CQRS.html) pattern to separate the read model and write model.
And the code organize as this:
1. `api` is the web layer to implement by Spring MVC
2. `core` is the business model including entities and services
3. `application` is the high level services for query with the data transfer objects
4. `infrastructure` contains all the implementation classes as the technique details
2017-08-18 16:40:21 +07:00
# Security
Integration with Spring Security and add other filter for jwt token process.
The secret key is stored in `application.properties`.
# Database
It uses a H2 in memory database (for now), can be changed easily in the `application.properties` for any other database.
# Getting started
2019-10-21 16:54:41 +07:00
You need Java 8 installed.
2017-08-18 16:40:21 +07:00
./gradlew bootRun
2019-10-21 16:54:41 +07:00
To test that it works, open a browser tab at http://localhost:8080/tags .
Alternatively, you can run
curl http://localhost:8080/tags
2017-08-18 16:40:21 +07:00
# Try it out with [Docker](https://www.docker.com/)
You need Docker installed.
2018-01-03 14:25:49 +07:00
docker-compose up -d
2019-10-21 16:54:41 +07:00
# Try it out with a RealWorld frontend
The entry point address of the backend API is at http://localhost:8080, **not** http://localhost:8080/api as some of the frontend documentation suggests.
2017-08-28 12:56:16 +07:00
# Run test
The repository contains a lot of test cases to cover both api test and repository test.
./gradlew test
2021-03-03 14:33:49 +07:00
# Use git pre-commit hook
Follow the instruction from [google-java-format-git-pre-commit-hook](https://github.com/a1exsh/google-java-format-git-pre-commit-hook) to use a `pre-commit` hook to make the code format style stable from different contributors.
2017-08-18 16:40:21 +07:00
# Help
2019-10-21 16:54:41 +07:00
Please fork and PR to improve the code.