1

I want to integrate angular 6 and spring boot application and final output make executable jar.I referred some tutorial and followed below steps .

1) Using ng build --prod i build angular project.

2) Created static folder under resource folder in spring boot and Copied dist folder to static folder .

3) Build the jar using maven and deployed in tomcat .But i am always getting 404 when i am trying to access index.html

My spring boot directory looks like below:

spring boot directory and index.html image

Can i need to change base href url in index.html ? Please suggest me .

Ajit Soman
  • 3,926
  • 3
  • 22
  • 41
gvsk225
  • 31
  • 1
  • 6
  • have you registered the resourceLocations ? Also please post what you've tried so far – CruelEngine Aug 16 '18 at 05:45
  • Hit http://localhost:8080/my-test/index.html in browser – Ajit Soman Aug 16 '18 at 07:27
  • The content of my-test must be directly under /static. I.e. you must not have that my-test directory under static. You need the files directly. – JB Nizet Aug 16 '18 at 08:21
  • Why do you want to deploy them together, I think it's not a good idea also "routing" will be an issue for you. In my opinion you should deploy them separate. Also check this: https://stackoverflow.com/questions/40769200/configure-spring-boot-for-spa-frontend – Muhammed Ozdogan Aug 16 '18 at 08:22
  • @MuhammedOzdogan It's a perfectly valid option. Spring Boot is perfectly able to serve static resources, and is perfectly able to deal with Angular routing with a simple filter. It's quite a classical combo. All this build of the jar file should be automated by Maven, though. – JB Nizet Aug 16 '18 at 08:28
  • @MuhammedOzdogan i need to pack a single jar that is my requirement – gvsk225 Aug 24 '18 at 06:52
  • @JBNizet i tried under static folder that is not helping always i am getting 404 – gvsk225 Aug 24 '18 at 06:53
  • @gvsk225 Could you try another html file that isn't an Angular index.html file under the static folder. – Muhammed Ozdogan Aug 24 '18 at 07:24

0 Answers0