Java Spring Boot 1.5.2示例返回404

Java Spring Boot 1.5.2示例返回404,java,spring,Java,Spring,所以我把这个例子拉了下来。我导入到Eclipse中,并调整POM,使其正确地拉入父POM,但其他所有内容都没有改变。但是当我点击网址时,我得到了一个404。下面是POM,这是我唯一改变的。我正在使用EclipseLuna将其作为Spring应用程序运行。日志似乎没有显示除未找到资源之外的任何内容。已验证是否调用了控制器的方法,因此它位于返回的“欢迎”视图名称之后 <?xml version="1.0" encoding="UTF-8"?> <project xmlns="htt

所以我把这个例子拉了下来。我导入到Eclipse中,并调整POM,使其正确地拉入父POM,但其他所有内容都没有改变。但是当我点击网址时,我得到了一个404。下面是POM,这是我唯一改变的。我正在使用EclipseLuna将其作为Spring应用程序运行。日志似乎没有显示除未找到资源之外的任何内容。已验证是否调用了控制器的方法,因此它位于返回的“欢迎”视图名称之后

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <!-- Your own application should inherit from spring-boot-starter-parent -->
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.2.RELEASE</version>
        <relativePath />
    </parent>
    <artifactId>spring-boot-sample-web-jsp</artifactId>
    <packaging>war</packaging>
    <name>Spring Boot Web JSP Sample</name>
    <description>Spring Boot Web JSP Sample</description>
    <url>http://projects.spring.io/spring-boot/</url>
    <organization>
        <name>Pivotal Software, Inc.</name>
        <url>http://www.spring.io</url>
    </organization>
    <properties>
        <java.version>1.7</java.version>
        <main.basedir>${basedir}/../..</main.basedir>
        <m2eclipse.wtp.contextRoot>/</m2eclipse.wtp.contextRoot>
    </properties>
    <dependencies>
        <!-- Compile -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
        </dependency>
        <!-- Provided -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-jasper</artifactId>
            <scope>provided</scope>
        </dependency>
        <!-- Test -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <useSystemClassLoader>false</useSystemClassLoader>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
尝试删除
spring boot starter tomcat
tomcat embed jasper的
provide
元素。
我也遇到了这个问题,它通过这样做解决了我的问题。

我下载了1.3.8.0发行版,效果很好。所以我的构建过程还可以。但我不知道1.5.2和1.3.8之间的差异会导致什么。听起来很有希望。但我对这两个依赖项都做了更改,做了一个Maven更新项目并重建了它,但仍然给了我一个404。这可能与你的建议非常相似,也有关联。
.w.s.m.m.a.ServletInvocableHandlerMethod : Method [sample.jsp.WelcomeController.welcome] returned [welcome]
o.s.w.s.v.ContentNegotiatingViewResolver : Requested media types are [text/html, application/xhtml+xml, image/webp, application/xml;q=0.9, */*;q=0.8] based on Accept header types and producible media types [*/*])
o.s.w.servlet.view.BeanNameViewResolver  : No matching bean found for view name 'welcome'
o.s.b.f.s.DefaultListableBeanFactory     : Invoking afterPropertiesSet() on bean with name 'welcome'
o.s.w.s.v.InternalResourceViewResolver   : Cached view [welcome]
o.s.w.s.v.ContentNegotiatingViewResolver : Returning [org.springframework.web.servlet.view.JstlView: name 'welcome'; URL [/WEB-INF/jsp/welcome.jsp]] based on requested media type 'text/html'
o.s.web.servlet.DispatcherServlet        : Rendering view [org.springframework.web.servlet.view.JstlView: name 'welcome'; URL [/WEB-INF/jsp/welcome.jsp]] in DispatcherServlet with name 'dispatcherServlet'
o.s.web.servlet.view.JstlView            : Rendering view with name 'welcome' with model {time=Wed Mar 15 13:59:42 EDT 2017, message=Hello Phil} and static attributes {}
o.s.web.servlet.view.JstlView            : Added model object 'time' of type [java.util.Date] to request in view with name 'welcome'
o.s.web.servlet.view.JstlView            : Added model object 'message' of type [java.lang.String] to request in view with name 'welcome'
o.s.web.servlet.view.JstlView            : Forwarding to resource [/WEB-INF/jsp/welcome.jsp] in InternalResourceView 'welcome'
o.apache.catalina.core.StandardWrapper   :   Returning non-STM instance
o.s.web.servlet.DispatcherServlet        : Bound request context to thread: org.apache.catalina.core.ApplicationHttpRequest@1077e52
o.s.web.servlet.DispatcherServlet        : DispatcherServlet with name 'dispatcherServlet' processing GET request for [/WEB-INF/jsp/welcome.jsp]
o.s.web.servlet.DispatcherServlet        : Testing handler map [org.springframework.web.servlet.handler.SimpleUrlHandlerMapping@6cee48] in DispatcherServlet with name 'dispatcherServlet'
o.s.w.s.handler.SimpleUrlHandlerMapping  : No handler mapping found for [/WEB-INF/jsp/welcome.jsp]
o.s.web.servlet.DispatcherServlet        : Testing handler map [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping@190641d] in DispatcherServlet with name 'dispatcherServlet'
s.w.s.m.m.a.RequestMappingHandlerMapping : Looking up handler method for path /WEB-INF/jsp/welcome.jsp
o.a.c.loader.WebappClassLoaderBase       : getResource(org/springframework/mail/javamail/mime.types)
o.a.c.loader.WebappClassLoaderBase       :   Delegating to parent classloader sun.misc.Launcher$AppClassLoader@a4be02
o.a.c.loader.WebappClassLoaderBase       :     findResource(org/springframework/mail/javamail/mime.types)
o.a.c.loader.WebappClassLoaderBase       :     --> Resource not found, returning null
o.a.c.loader.WebappClassLoaderBase       :   --> Resource not found, returning null
.PathExtensionContentNegotiationStrategy : Loading default Java Activation Framework FileTypeMap
javax.activation                         : MimetypesFileTypeMap: load HOME
javax.activation                         : MimetypesFileTypeMap: load SYS
javax.activation                         : MimetypesFileTypeMap: load JAR
o.a.c.loader.WebappClassLoaderBase       :     findResources(META-INF/mime.types)