In this article, we are going to check how to deploy Angular 6 & Spring Boot REST application as a single deployment unit but however best practice is to separate Spring boot and Angular application so that we decouple the client code and server code, hence the application becomes highly scalable and manageable. But sometimes there could be scenarios for example. small application/teams it is advisable to package as a single unit and deploy them. In this article, we are going to check how to use maven resources plugin and spring boot jar packaging to build and deploy as a single unit.
Quick Snapshot
In the first part of the article, we would be creating a new Angular 6 client using Angular CLI & install prerequisites. We would be installing Node.js which is a cross-platform runtime system and runtime environment for applications written in JavaScript language and npm package manager for downloading packages.
node -v & npm –v
npm install -g @angular/cli
ng -v
/api/hello
and do maven compile to check if the build is a success. ng new
command with Angular CLI npm start
the command from the workspace. http://localhost:4200
node_modules
folder & click on apply. We wouldn’t need node_modules
a folder because it would be generated during the build process. node_modules
folder. app.component.css
to update color as ‘black’ (optional step) app.component.ts
to update the title as required (optional step) npm start
to view the changes ng build –prod
command for generating production build artifacts. /src/main/resources/static
the folder to Spring Boot Project. Following is the POM configuration <plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-resources</id>
<phase>validate</phase>
<goals><goal>copy-resources</goal></goals>
<configuration>
<outputDirectory>${build.directory}/classes/static/</outputDirectory >
<resources>
<resource>
<directory>../angular6-client/dist</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
Java –jar
the command to launch the application, you should see the Angular application served from the static folder.
Congrats! today we have learned how to use maven resources plugin and spring boot jar packaging to build and deploy as a single unit.
The sample code used in this article can be found at Github here.
There are few things as valuable to a business as well-designed software. Organizations today rely…
The cryptocurrency industry is being reshaped by the fusion of blockchain technology and artificial intelligence…
Introduction Artificial Intelligence (AI) has also found its relevance in graphic design and is quickly…
Imagine a world where the brilliance of Artificial Intelligence (AI) meets the unbreakable security of…
In today’s fast-paced digital landscape, automation is not just a luxury but a necessity for…
The world of casino gaming has leveraged the emerging technology advancements to create immersive and…
This website uses cookies.