🔴 The Error You're Seeing

Confirm this matches your console output. If it does, you're in the right place.

ERROR LOG2026-02-20 16:10:40.100 WARN 8842 --- [nio-8080-exec-1] o.s.web.servlet.resource.NoResourceFoundException: No static resource index.html.

⚡ Quick Fix Works 80% of the time

Ensure index.html is in src/main/resources/static/ and configure SPA forwarding.

@Override public void addResourceHandlers(ResourceHandlerRegistry registry) { registry.addResourceHandler("/**").addResourceLocations("classpath:/static/"); }

🧠 Why this Happens

Tap to expand the deep technical explanation

In Spring Boot 3, `NoResourceFoundException` is thrown when a static resource cannot be found. If your Angular app is packaged inside the Spring Boot JAR, and a user hits a deep link like `/users/1`, Spring Boot looks for a file named `users/1` in the `static` folder. It doesn't find it, and because it doesn't know to forward to `index.html`, it throws this exception.

The HITEC City Parking Spot Analogy:

It's like a receptionist trying to find an employee named 'Users/1' in the company directory. They don't exist, so the receptionist hangs up. They should have forwarded the call to the front desk (index.html) instead.

🔁 How to Reproduce Confirm this is your error

Create a Spring Boot 3 app. Put an `index.html` in `src/main/resources/static/`. Start the app. Open a browser and go to `http://localhost:8080/dashboard` (a frontend route). Spring Boot will throw this exception.

🛠️ Solutions (5 Ways to Fix)

Solution 1✓ Most common cause

Configure SPA forwarding

👉 Use this when serving a frontend SPA from Spring Boot.

Tell Spring to forward any unknown route to `index.html` so the frontend router can take over.

@Configuration public class WebConfig implements WebMvcConfigurer { @Override public void addViewControllers(ViewControllerRegistry registry) { // Forward unknown routes to index.html registry.addViewController("/{spring:[^\\.]*}").setViewName("forward:/index.html"); } }
Solution 2

Ensure index.html is in the correct folder

👉 Use this if the file is missing from the JAR.

Spring Boot only serves static files from `src/main/resources/static/`, `public/`, or `META-INF/resources/`. Move your file there.

# Move file mv src/main/resources/index.html src/main/resources/static/index.html
Solution 3

Disable NoResourceFoundException (Not Recommended)

👉 Use this if you want the old Spring Boot 2 behavior of returning a 404 Whitelabel Page.

Turn off the strict resource checking introduced in Spring Boot 3.

# application.properties spring.mvc.throw-exception-if-no-handler-found=false spring.web.resources.add-mappings=true
Solution 4

Fix Maven Shade / JAR packaging

👉 Use this if the file is in the right folder but missing at runtime.

Ensure your `pom.xml` isn't excluding `src/main/resources` during the build process.

<build> <resources> <resource> <directory>src/main/resources</directory> <includes> <include>**/*.*</include> </includes> </resource> </resources> </build>
Solution 5

Check for context path

👉 Use this if your app runs under `/api`.

If `server.servlet.context-path=/api` is set, the frontend must be served from `/api/index.html`, not `/index.html`.

# Ensure frontend base href matches the context path # index.html: <base href="/api/">

📋 Version Notes

Spring Boot 2.x

Returns 404 Whitelabel Error Page for missing resources.

Spring Boot 3.x

Throws NoResourceFoundException. Stricter handling of static resources.

🛡️ How to Prevent This Next Time

If you are deploying a SPA and a Spring Boot API separately, do not package the SPA inside the Spring Boot JAR. Use Nginx or a CDN to host the frontend.