Coder Social home page Coder Social logo

luzzetti / spring-boot-angular-scaffolding Goto Github PK

View Code? Open in Web Editor NEW

This project forked from little-pinecone/spring-boot-angular-scaffolding

0.0 0.0 0.0 2.13 MB

Spring Boot and Angular multi-module project that builds as a single jar.

Home Page: http://keepgrowing.in/java/springboot/integrate-angular-with-a-spring-boot-project/

License: The Unlicense

Shell 5.50% JavaScript 4.29% Java 24.02% TypeScript 57.12% HTML 8.74% SCSS 0.33%

spring-boot-angular-scaffolding's Introduction

spring-boot-angular-scaffolding

keep growing logo

Quality Gate Status Maintainability Rating Reliability Rating

Bugs Coverage Vulnerabilities Code Smells Technical Debt

GitHub

To learn how to set up a project like this one, check out the Integrate Angular with a Spring Boot project post.

This project is a multi-module application, using the following frameworks: Spring Boot for the backend and Angular for the frontend. The project can be built into a single jar file using Maven.

Getting Started

Prerequisites

Backend:

Frontend:

Running the project

First, clone this repository.

Then, build it locally with:

mvn clean install

You can run the project from command line with:

mvn spring-boot:run -Dspring-boot.run.profiles=dev

As a result, you should be able to visit the home page on http://localhost:8080/:

home page screenshot

Profiles summary

The project can be built with various different profiles to allow for flexible configuration. Below you'll find a short summary of the available profiles.

Spring profiles

  • dev - for local development. Allows things like handling requests from http://localhost:4200/.
  • angular - special profile used for client code generation. Applied automatically when the angular Maven profile is enabled.

Maven profiles

  • sonar-cloud - for code analysis on push to master
  • code-coverage - for including code coverage reports from the backend module during a sonar analysis
  • frontend-pre-sonar - for including code coverage reports from the frontend module during a sonar analysis
  • frontend-sonar - for running only a sonar analysis for the frontend module
  • angular - for generating client code

API documentation

The backend module serves one endpoint for testing purposes. First, build and run the application. Then you'll be able to reach the API docs.

Swagger

The Swagger UI page: http://localhost:8080/swagger-ui.html.

OpenAPI

Client code generation

Compatibility

Right now openapi-generator supports Angular 11.0.0. Although the generated code works with Angular 12+ used in this project, it's strongly recommended to update the generator plugin as soon as it starts supporting Angular 12.0.0 (see Issue #9511).

Generating code

To run client code generation using the openapi-generator-maven-plugin execute the following command:

cd backend
mvn clean verify -Pangular -DskipTests

The application will be started so that the API specification can be obtained from the Open API endpoint. The generated code is available in the frontend/src/main/angular/src/backend directory. Don't edit those files manually.

Working with frontend on a local environment

If you want to see how changes you make in the frontend code affect the application you don't need to build it together with the backend module every time (mvn clean install). Use the following commands:

mvn spring-boot:run -Dspring-boot.run.profiles=dev
cd frontend/src/main/angular
ng serve

and visit http://localhost:4200/. The frontend application reloads automatically on code change.

Running test suits

Backend

Run unit tests with the following command in the project directory:

mvn test

Run all tests with the following command in the project directory:

mvn verify

Frontend

Run all tests for the Angular code with:

cd frontend/src/main/angular
ng test

SonarQube analysis on a local environment

SonarQube Prerequisites

Full analysis

You can run analysis for the whole project (both backend and frontend):

mvn clean verify sonar:sonar -Pfrontend-pre-sonar -Pcode-coverage -Dsonar.login=your_username -Dsonar.password=your_password

Backend analysis

You can run a separate analysis for the backend module:

cd backend
mvn clean verify sonar:sonar -Pcode-coverage -Dsonar.login=your_username -Dsonar.password=your_password

Frontend analysis

You can run a separate analysis for the frontend module:

cd frontend
mvn sonar:sonar -Pfrontend-pre-sonar -Dsonar.login=your_username -Dsonar.password=your_password

Or use the shell script which you can find in the closing paragraphs of the How to add an Angular module built with Maven to a SonarQube analysis post.

Verifying results

Visit the Projects page and choose the right project. Depending on which modules were analysed you should see one, two, or three projects.

Forking this repository

Update project metadata

  • Make sure to provide your own values for <name>, <description>, <artifactId> and <groupId> in the pom.xml, backend/pom.xml and frontend/pom.xml files.

GitHub Actions and SonarCloud analysis

  • Remove the .github/workflows/build.yml file if you don't want to configure GitHub Actions for your repository.
  • If you don't want to configure SonarCloud for your repository: remove the sonar-cloud profile from pom.xml, <sonar.projectKey> and <sonar.projectName> from backend/pom.xml and all <sonar…> properties from frontend/pom.xml
  • If you do want to configure GitHub Actions and SonarCloud analysis, add your own SONAR_TOKEN to your repository and customize all mentioned above<sonar…> properties in the pom.xml files.

Built With

Table of contents generated with markdown-toc

spring-boot-angular-scaffolding's People

Contributors

little-pinecone avatar dependabot[bot] 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.