javaangularspringhostingcpanel

Deploy frontend in angular and backend in java in cpanel


I have used angular framework for frontend development and created spring boot application for backend. To run my application on my local server(my computer), I first run spring boot application in eclipse and angular application through angular cli. But how can I deploy and host my project to cpanel?


Solution

  • Step 1) Angular build command - "ng build --prod" . This will create a dist folder in you angular project main directory, if you navigate in to this directory you will see folders where assets, index.html, main.xxxxxxxx.js, polyfills.xxxxxxxx.js and runtime.xxxxxxxxx.js etc will be available

    Angular dist folder (miracleApp is my app name, so all files will be under this)

    Step 2) Copy all the above files from the dist directory and paste them in src/main/resources directory of your java project

    Java Project

    Step 3) Now do a maven build (hope yours is a maven project) using "package" as the goal and if build is successful you will see a target folder with either a jar or a war (depending on what you choose packaging option in pom.xml) file which will have all your angular and java code and ready to use

    Step 4) Now go to your service providers cpanel (make sure your service provider accepts java application deployments and not just php, I faced this issue sometime back where service providers allow only php applications) and use this packaged jar or war file for deployment on the provided server