Spring boot + MyBatis codebase containing real world examples (CRUD, auth, advanced patterns, etc) that adheres to the RealWorld 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 repo.
The application uses Spring boot (Web, Mybatis).
- Use the idea of Domain Driven Design to separate the business term and infrastruture term.
- Use MyBatis to implement the Data Mapper pattern for persistence.
- Use CQRS pattern to separate the read model and write model.
And the code organize as this:
api
is the web layer to implement by Spring MVCcore
is the business model including entities and servicesapplication
is the high level services for query with the data transfer objectsinfrastructure
contains all the implementation classes as the technique details
Integration with Spring Security and add other filter for jwt token process.
The secret key is stored in application.properties
.
It uses a H2 in memory database (for now), can be changed easily in the application.properties
for any other database.
You need Java 8 installed.
./gradlew bootRun
To test that it works, open a browser tab at http://localhost:8080/tags .
Alternatively, you can run
curl http://localhost:8080/tags
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.
The repository contains a lot of test cases to cover both api test and repository test.
./gradlew test
#Additional configuration
To start project with
./gradlew bootRun
or
./gradle build && java -jar ./build/lib/*.jar
you need to define next environment variables:
DB_USERNAME - username which will be used to connect to MySQL DB instance
DB_PASSWORD - password which will be used to connect to MySQL DB instance
DB_URL - url by which application can access MySQL
DB_PORT - port by which application can access MySQL
DB_NAME - database name which will be used to store information