Building a Java Angular application tutorial and best practices

Step-by-step guide to building a full-stack Java and Angular application. Covers setup, deployment, error handling, and best practices for a production-ready app.

In this page I try to describe step-by-step what is needed to build a fullstack application with Java (Spring Boot) and Angular.

This is a minimalistic approach that is running successfully in production in some international companies. There are multiple approaches and architecture possible and there is no 'best solution' only solutions that work best in your context.

This is a permanent work in progress project, I'll add links and video and update them. For any suggestion or contribution you can contact me.

The basis of your application

SubjectDescriptionBlogVideos
IDE choiceTBDTBD
IDE configurationSome plugins that I usually use to simplify my workflowTBDTBD
Deploy Angular with Spring Boot in the same executable JAR / WARFrontend copied inside of backendAngular with Java
Deploy Angular with Spring Boot in the same executable JAR / WAR (3 tier)Frontend, backend and delivery are separatedDeploy Java Angular One
Deploy your application in DockerDeploy Spring in Docker
Fix the 404 error when refreshing the Angular page in a Java applicationfix 404 error
Fix CORS errorfix CORS error
Fix Whitelabel errorfix Whitelabel error

| OpenAPI generator                                                         |                                                         | OpenAPI generator                            |        |

Angular specific steps

StepsDescriptionBlogVideos
Angular, Typescript and Node version compatibility matrixWhich version of Node.js and Angular are compatible?https://marmo.dev/angular-typescript-node
Node and Angular Setup using NVM (Linux)https://marmo.dev/angular-docker-linux
Dev Server configurationConfigure multiple environments and add a proxyDev server configuration
Test with CypressAngular with Cypress and Java
Allow public access to the Angular Dev Server during the developmentExternal access to the dev server
Deploy Angular with Docker and NGINXDeploy with docker and nginx
Common errorsCommon errors

Angular UI (optional)

DescriptionBlogVideos
Display a tooltip on a disabled buttonMaterial Tooltip
File uploadFile Upload tutorial
How to store user information between sessions in a Cookie in Angularangular-cookie
Send an image from the Java backend to Angular using REST servicesSend an image from the Java backend to Angular
Export your data to CSV using Typescriptexport your data to CSV using Typescript
Enums in Angular Templatehow to use enums in the template
Right click menuRight click menu
Repeat an HTTP request every x seconds / minutesRepeat HTTP request
Angular best componentsBest components
Angular Material: sort complex objects using MatTableDataSourceMatTableDataSource
Unsaved changes warning in Angularhttps://marmo.dev/angular-save-on-exit
Fix: CommonJS or AMD dependencies can cause optimization bailoutsRemove moment.jshttps://marmo.dev/angular-momentjs-warning
Crazy: Add Angular (Web Component) to an existing websiteAngular Elements using 2D canvashttps://marmo.dev/angular-rxjs-examples

Java / Spring Boot specific steps

DescriptionBlogVideos
Configure the Java Virtual Machine for DockerJava Docker Setup
SpringBoot best practicesBest practices
Autoconfiguration package and the missing JPA EntitiesJPA in modules
How execute code when your Spring Boot application starts@PostConstruct and @PreDestroy
Organise and tests the exceptions using ControllerAdviceCentralise the Exception Managementhttps://marmo.dev/rest-controller-advice
Deploy your app with DockerDeploy Spring Boot with Docker
Generate a SitemapGenerate a sitemap.xml
Execute code at startupCode at startup
Hot deployment during developmentHot redeploy
Override Maven dependenciesUseful when you are blocked by CVEhttps://marmo.dev/maven-override-dependency

Spring Boot testing

DescriptionBlogVideos
Override properties in your test classesOverride properties defined in .properties in your test classhttps://marmo.dev/spring-test-properties
Liquibase with Spring for your testsUpdate your database
Data Tests with H2H2 with Spring Boot and JPA
Test @RestControllerTest @RestController
How to test our REST servicesTest REST in SpringBoot