FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

PouyaPouryaie/basicFeaturesForSpringProject at 1.4.0 · GitHub

Repository files navigation

BasicFeaturesForSpringProject

This project, implement instance of basic feature,
you maybe want use for App base on Spring-boot

basicFeature

  • spring-web
  • spring-jpa
    • with custom configuration for PersistenceContext
  • Connection-pool
    • HikariCp with Possibility of customization
  • Ehcache
    • customize cache config and implement log for cache
  • Log4j2
    • logging and config log-message
  • Exception management
  • MapStruct
    • mapper tools for map view to entity and vice-versa
  • Validation handler
    • use annotation for validation
    • use log for validation error
    • define your validation and use for model
  • TestUtils
    • generator data with javaFaker
    • unit and integration test with Spock Framework
    • SwaggerAPI for show detail of Rest endpoint
    • TestContainer use for run db as dockerImage for test, and after that image is stop
  • decoupling layer
    • controller, service and repository layer for easy extend
  • flexible search
    • use CriteriaQuery and CriteriaBuilder for search base on Entity

Run guide

Run for develop and debug:

1 - check active profile on dev
2 - run postgre sql on 5432 and create database myapp
3 - run app
4 - app.generator.enabled properties set to true, when you want to generate fake data

Run as docker image:

1 - check active profile on docker and package project
2 - create image from app: docker build -t springapp:latest .
3 - run app: docker compose run

Features

exception feature

1 - use AppException for define your own error Exception
2 - user HttpExceptionModel for define your own error message and show to client
3 - use HttpErrorCode for unifying error code in project

validation feature

1 - create your own validation type
2 - define your own validation process for entity
3 - use "@validator" annotation on field of entity for validate
4 - log for validation and save error-message in log file

search v2 base on NativeQuery feature

1 - query clause, order for result and pagination can define in client Request as queryString and handle in AbstractController
2 - buildNativeQueryCondition method in Utils class use for create native query base on request queryString
3 - dynamic order and direction for sort data handle in daoRepository
4 - more detail about search feature, see searchEngineV2.drawio
5 - sample rest search request:

search v3 base on CriteriaBuilder feature

1 - query clause, order for result and pagination can define in client Request as queryString and handle in AbstractController
2 - define Quartet from javaTuples lib that use for define name of field from client, name of field in model, sqlOperation and sqlCondition
3 - define Sort.Order object of spring with getSortOrderFromPagedQuery method to use for order by Clause
4 - then use getUserQueryWithCriteriaBuilder in userRepository for create query and get Result
5 - sample rest search request:

test feature

1 - generate sample data baseOn model with javaFaker
2 - Spock framework use for test
3 - sample test define in test directory with groovy language
4 - Swagger Api for show details of endpoints
5 - In order to change swagger url, you must be change springdoc.swagger-ui.path property in application-dev.properties
6 - TestContainer for run db as dockerImage, properties config exist in application-test.properties

dataSource feature

1 - choose between use simpleDataSource or HikariCp datasource
2 - you can customize properties for dataSource in application.properties

About

This Repo contain basic features for develop application base on spring boot. some of this features is RestApi, cache, hibernate, mapper, test, docker and .....

Topics

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages


Back | FazBrowse Home | New Git URL