java spring引导不会为JSP返回404,除非编译tomcat maven依赖范围?
当我试图呈现jsp文件时,spring boot返回了404。我的maven配置有spring boot starter父版本1.4.0。作为版本发布
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.0.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
我正在运行嵌入式Tomcat servlet容器
我在我的^{cd3>}文件中找到了这个SO post{a1},并设置了所需的spring.mvc.view.prefix
和spring.mvc.view.suffix
属性
仍然是404
然后我找到了这个SO postspring-boot-not-finding-jsp-pages-in-war-file,并在我的pom
文件中添加了必要的依赖项:
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
仍然是404
删除<scope>provided</scope>
标记后,一切都开始工作。考虑到这个标记可能导致spring boot的类路径不同,因此启用了不同的功能,我使用--debug
打开了spring boot配置报告,并区分了有scope
标记和没有scope
标记的输出。没有区别。两者在Positive matches
部分都有以下行:
WebMvcAutoConfiguration.WebMvcAutoConfigurationAdapter#defaultViewResolver matched - @ConditionalOnMissingBean (types: org.springframework.web.servlet.view.InternalResourceViewResolver; SearchStrategy: all) found no beans (OnBeanCondition)
有人能解释为什么它没有provided
作用域就可以工作吗
共 (0) 个答案