Configure ViewResolver with Spring Boot and annotations gives No mapping found for HTTP request with URI error
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Introduction
The error message stating no mapping found for an HTTP request URI is often blamed on ViewResolver, but mapping and view resolution are separate stages in Spring MVC. Mapping failure means Spring never reached the controller method, so view configuration is not the first suspect. A reliable fix comes from checking controller annotations, URL paths, template locations, and MVC setup order.
Understand Request Mapping Versus View Resolution
Spring handles a request in two major steps:
- map request path to a controller method
- resolve returned view name to a template
If the first step fails, you get no mapping found. ViewResolver only participates after a controller method returns a view name.
Minimal Working MVC Example
Use @Controller for HTML views and return logical view names.
Template file should be at src/main/resources/templates/home.html when using Thymeleaf starter defaults.
Typical Thymeleaf Configuration
With Spring Boot starters, explicit resolver beans are often unnecessary. Keep configuration simple unless you need custom behavior.
If you define custom resolver beans, ensure they do not conflict with Boot auto-configuration.
Common Causes of No Mapping Found
Most incidents come from one of these:
- controller package is outside component scan base package
- used
@RestControllerwhile expecting template rendering - method mapped to
/homebut request hits/or a different context path - wrong HTTP method, such as POST request to
@GetMapping - custom servlet context path not reflected in request URL
Fast diagnostic step:
This logs handler mapping attempts and shows which paths were considered.
Verify Component Scan Scope
Spring Boot scans from the package of your main application class downward. If controllers live outside that tree, they are not discovered.
Place controllers under com.example... package hierarchy, or define explicit scan base packages.
When Manual ViewResolver Is Needed
If you render JSP on a traditional servlet container, manual resolver setup is common. For Thymeleaf in Boot apps, manual beans are rarely required.
Use this only when your template technology requires it.
End-to-End Test to Catch Mapping Errors Early
Add a lightweight MVC test to assert mapping and view resolution.
This prevents accidental mapping regressions during refactors.
Common Pitfalls
A common pitfall is configuring view resolvers repeatedly while the real issue is missing controller mapping. Another is mixing @RestController and view templates, which returns raw response bodies instead of resolving views. Teams also place templates in wrong directories or use mismatched suffix settings, causing secondary rendering errors after mapping is fixed. Finally, custom security rules can block routes and look like mapping failures unless logs are inspected carefully.
Summary
- Mapping errors happen before view resolution, so debug controller routes first.
- Use
@Controllerplus correct@GetMappingpaths for template endpoints. - Keep controllers inside component scan scope.
- Prefer Boot defaults for Thymeleaf unless custom resolver behavior is required.
- Add MVC tests and web debug logs to catch URI mapping issues early.
Related reading
- Configuring GSuite to work with route 53 - MX record doesn't have 2 fields error
- Configuring Kafka to accept clients both from inside and outside docker
- Confluent's Kafka REST Proxy vs Kafka Client
- Connect from one Docker container to another
- Configuring base package for component scan in Spring boot test
- Configuring ConnectionFactory for RabbitMQ in Spring Boot AMQP
- Connect to Kafka through SOCKS Proxy
- Connect to mysql on Amazon EC2 from a remote server

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.