GithubHelp home page GithubHelp logo

harsard / spring-boot-blog-app Goto Github PK

View Code? Open in Web Editor NEW

This project forked from gtiwari333/spring-boot-blog-app

0.0 0.0 0.0 338 KB

Application to demonstrate several features of Spring Boot

JavaScript 0.18% Java 80.13% Groovy 2.61% CSS 0.36% HTML 16.59% Dockerfile 0.12%

spring-boot-blog-app's Introduction

A BlogApp with Spring Boot

Intro

This is a simple micro blogging application where you can post a note/blog with attachments and other can view it.

The default username/passwords are listed on : gt.app.Application.initData, which are:

  • system/pass
  • user1/pass
  • user2/pass

Requirements

How to Run

  • Clone/Download and Import project into your IDE, compile and run Application.java

  • Update run configuration to run maven goal wro4j:run Before Launch. It should be after 'Build' OR

  • ./mvnw compile spring-boot:run //if you don't have maven installed in your PC

OR

  • ./mvnw compile spring-boot:run //if you have maven installed in your PC

And open http://localhost:8080 on your browser

Run Tests

Running full tests

./mvnw clean verify

Running unit tests only (it uses maven surefire plugin)

./mvnw compiler:testCompile resources:testResources surefire:test

Running integration tests only (it uses maven-failsafe-plugin)

./mvnw compiler:testCompile resources:testResources failsafe:integration-test

Code Quality

The error-prone runs at compile time.
The modernizer checkstyle and spotbugs plugin are run as part of maven test-compile lifecycle phase. use `mvn spotbugs:gui' to
SonarQube scan

Run sonarqube server using docker docker run -e SONAR_ES_BOOTSTRAP_CHECKS_DISABLE=true -p 9000:9000 sonarqube:latest

Perform scan: ./mvnw sonar:sonar ./mvnw sonar:sonar -Dsonar.login=admin -Dsonar.password=admin

View Reports in SonarQube web ui:

  • visit http://localhost:9000
  • default login and password are admin, you will be asked to change password after logging in with default username/password
  • (optional) change sonarqube admin password without logging in: curl -u admin:admin -X POST "http://localhost:9000/api/users/change_password?login=admin&previousPassword=admin&password=NEW_PASSWORD"
  • if you change the password, make sure the update -Dsonar.password=admin when you run sonarqube next time

Dependency vulnerability scan

Owasp dependency check plugin is configured. Run ./mvnw dependency-check:check to run scan and open dependency-check-report.html from target to see the report.

Dependency/plugin version checker

./mvnw versions:display-dependency-updates
./mvnw versions:display-plugin-updates

Included Features/Samples

  • GraalVM native image generation
  • Modular application
  • Data JPA with User/Authority/Note/ReceivedFile entities, example of EntityGraph
  • Default test data created while running the app
  • Public and internal pages
  • MVC with thymeleaf templating
  • File upload/download
  • Live update of thymeleaf templates for local development
  • HTML fragments
  • webjar - bootstrap4 + jquery
  • Custom Error page
  • Request logger filter
  • Swagger API Docs with UI ( http://localhost:8080/swagger-ui.html)
  • @RestControllerAdvice, @ControllerAdvice demo
  • CRUD Note + File upload
  • Spring / Maven profiles for dev/prod ...
  • Dockerfile to run images
  • Docker maven plugin to publish images (follow docker-steps.md)
  • Deploy to Amazon EC2 ( follow docker-steps.md )
  • Code Generation: lombok, mapstruct
  • H2 db for local, Console enabled for local ( http://localhost:8080/h2-console/, db url: jdbc:h2:mem:testdb, username:sa)
  • MySQL or any other SQL db can be configured for prod/docker etc profiles
  • User/User_Authority entity and repository/services
    • login, logout, home pages based on user role
  • Security with basic config
  • Domain object Access security check on update/delete using custom PermissionEvaluator
  • public home page -- view all notes by all
  • private pages based on user roles
  • Test cases - unit/integration with JUnit 5, Mockito and Spring Test
  • Tests with Spock Framework (Groovy 3, Spock 2)
  • e2e with Selenide, fixtures. default data generated using Spring
  • Architecture test using ArchUnit
  • Email
  • Account management/Signup UI

Future: do more stuff

  • background jobs with Quartz
  • Liquibase/Flyway change log
  • Integrate Markdown editor for writing notes

Dependency/plugin version checker

`./mvnw versions:display-dependency-updates`
`./mvnw versions:display-plugin-updates`

Generate native executable:

  • Required: GraalVM 22.3+ (for Spring Boot 3)

  • Install using sdkman sdk install java 22.3.r17.ea-nik sdk use java 22.3.r17.ea-nik

  • Create native executable ./mvnw native:compile -Pnative,dev

  • Run it ./target/note-app

OR

  • Generate docker image with native executable ./mvnw spring-boot:build-image -Pnative,dev
  • Run it docker run --rm -p 8080:8080 docker.io/library/note-app:3.0.0-RC1

Native Test:

  • Run with ./mvnw test -PnativeTest
  • Spring Boot 3.0.0: native-test is not working due to spock ( and possibly other dependencies too)

spring-boot-blog-app's People

Contributors

gtiwari333 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.