Spring Boot and Angular SPA Developed As One Project

I am developing a Spring Boot server with Angular generated HTML/JS GUI. It will be deployed to a production environment on AWS ElasticBeanstalk, which requires a single 'fat' runnable JAR. I have created a Spring Boot server project, and can produce the JAR which runs locally inside IntelliJ, and I can deploy the JAR to AWS successfully. If I add a simple index.html file to the resources/static folder it is served up.

How do I progress this to an Angular SPA? I want to have a single IntelliJ project for both client and server, which all builds into a single JAR file, and is served from a single webserver (embedded Tomcat managed by Spring Boot).

I could have a second instance of IntelliJ running to manage the Angular project, but that would use node.js to serve the Angular pages and so effectively I have two webservers running on different ports which doesn't reflect my production architecture. It also means I have to explicitly specify full URLs rather than use relative URLs which is a configuration nightmare, and I then have CORS issues too. I have searched but can't find any tutorials or examples of anyone doing this, but it seems an obvious way to develop for this stack.

Can you tell me if this is possible, a good or bad approach, and point me in the right direction please?

3

Please sign in to leave a comment.