I'm getting 404s returned by spring boot when trying to render jsp files. My maven config has spring-boot-starter-parent version 1.4.0.RELEASE as the version.
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.0.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
I am running the embedded Tomcat servlet container.
I found this SO post spring-boot basic JSP 404 Not Found and set the required spring.mvc.view.prefix
and spring.mvc.view.suffix
properties in my application.properties
file.
Still 404s.
I then found this SO post spring-boot-not-finding-jsp-pages-in-war-file and added the requisite dependencies in my pom
file:
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
Still 404s.
On removing the <scope>provided</scope>
tag, everything started to work. Thinking this tag may have resulted in a different classpath for spring boot and hence turned on a different feature, I turned on the spring boot configuration report using --debug
and diffed the output with and without the scope
tag. There was no difference. Both have the following line in the Positive matches
section:
WebMvcAutoConfiguration.WebMvcAutoConfigurationAdapter#defaultViewResolver matched - @ConditionalOnMissingBean (types: org.springframework.web.servlet.view.InternalResourceViewResolver; SearchStrategy: all) found no beans (OnBeanCondition)
Can anyone explain why it works without the provided
scope?