Whitelabel错误页面 - 出现意外错误(type = Not Found,status = 404).Spring启动应用程序

时间:2017-04-19 19:52:42

标签: spring eclipse spring-mvc spring-boot thymeleaf

我正在

白标错误页面
此应用程序没有/ error的显式映射,因此您将此视为后备。
Thu Apr 20 01:11:57 IST 2017
出现意外错误(type = Not Found,status = 404) *没有留言**

BookstoreApplication.java

package com.bookstore;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class BookstoreApplication {

    public static void main(String[] args) {
        SpringApplication.run(BookstoreApplication.class, args);
    }
}

HomeController.java

package com.bookstore.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class HomeController {
    @RequestMapping("/")
    public String index() {
        return "index";
    }
}

的pom.xml

 <?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>

    <groupId>com.bookstore</groupId>
    <artifactId>bookstore</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>Bookstore</name>
    <description>frontend part for our bookstore project</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.4.3.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <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>
        </plugins>
    </build>


</project>

的index.html

    <!DOCTYPE html>
    <html lang="en">
      <head>
        <meta charset="utf-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="viewport" content="width=device-width, initial-scale=1" />

        <title>Navbar Template for Bootstrap</title>

        <!-- Bootstrap core CSS -->
        <link href="/css/bootstrap.min.css" rel="stylesheet" />

        <!-- Custom styles for this template -->
        <link href="/css/style.css" rel="stylesheet" />
      </head>

      <body>

        <div class="container">

          <!-- Static navbar -->
          <nav class="navbar navbar-default">
            <div class="container-fluid">
              <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
                  <span class="sr-only">Toggle navigation</span>
                  <span class="icon-bar"></span>
                  <span class="icon-bar"></span>
                  <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand" href="#">Project name</a>
              </div>
              <div id="navbar" class="navbar-collapse collapse">
                <ul class="nav navbar-nav">
                  <li class="active"><a href="#">Home</a></li>
                  <li><a href="#">About</a></li>
                  <li><a href="#">Contact</a></li>
                  <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>
                    <ul class="dropdown-menu">
                      <li><a href="#">Action</a></li>
                      <li><a href="#">Another action</a></li>
                      <li><a href="#">Something else here</a></li>
                      <li role="separator" class="divider"></li>
                      <li class="dropdown-header">Nav header</li>
                      <li><a href="#">Separated link</a></li>
                      <li><a href="#">One more separated link</a></li>
                    </ul>
                  </li>
                </ul>
                <ul class="nav navbar-nav navbar-right">
                  <li class="active"><a href="./">Default <span class="sr-only">(current)</span></a></li>
                  <li><a href="../navbar-static-top/">Static top</a></li>
                  <li><a href="../navbar-fixed-top/">Fixed top</a></li>
                </ul>
              </div><!--/.nav-collapse -->
            </div><!--/.container-fluid -->
          </nav>

          <!-- Main component for a primary marketing message or call to action -->
          <div class="jumbotron">
            <h1>Test of </h1>
            <p>This example is a quick exercise to illustrate how the default, static navbar and fixed to top navbar work. It includes the responsive CSS and HTML, so it also adapts to your viewport and device.</p>
            <p>
              <a class="btn btn-lg btn-primary" href="../../components/#navbar" role="button">View navbar docs &raquo;</a>
            </p>
          </div>

        </div> <!-- /container -->
    <!-- Bootstrap core JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
    <script src="/js/bootstrap.min.js"></script>
  </body>
</html>

application.properties

spring.thymeleaf.cache=false

控制台

2017-04-20 01:10:35.000  INFO 8644 --- [           main] com.bookstore.BookstoreApplication       : Starting BookstoreApplication on DESKTOP-12BK4L1 with PID 8644 (started by Avinash Kharche in C:\Users\Avinash Kharche\ECommerce_Spring_Neon\Bookstore)
2017-04-20 01:10:35.005  INFO 8644 --- [           main] com.bookstore.BookstoreApplication       : No active profile set, falling back to default profiles: default
2017-04-20 01:10:35.527  INFO 8644 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@67d48005: startup date [Thu Apr 20 01:10:35 IST 2017]; root of context hierarchy
2017-04-20 01:10:37.621  INFO 8644 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2017-04-20 01:10:37.641  INFO 8644 --- [           main] o.apache.catalina.core.StandardService   : Starting service Tomcat
2017-04-20 01:10:37.643  INFO 8644 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.6
2017-04-20 01:10:37.826  INFO 8644 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2017-04-20 01:10:37.828  INFO 8644 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 2308 ms
2017-04-20 01:10:38.119  INFO 8644 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Mapping servlet: 'dispatcherServlet' to [/]
2017-04-20 01:10:38.124  INFO 8644 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
2017-04-20 01:10:38.125  INFO 8644 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2017-04-20 01:10:38.125  INFO 8644 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2017-04-20 01:10:38.125  INFO 8644 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]
2017-04-20 01:10:38.554  INFO 8644 --- [           main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@67d48005: startup date [Thu Apr 20 01:10:35 IST 2017]; root of context hierarchy
2017-04-20 01:10:38.672  INFO 8644 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/]}" onto public java.lang.String com.bookstore.controller.HomeController.index()
2017-04-20 01:10:38.679  INFO 8644 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2017-04-20 01:10:38.679  INFO 8644 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2017-04-20 01:10:38.748  INFO 8644 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-04-20 01:10:38.748  INFO 8644 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-04-20 01:10:38.814  INFO 8644 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-04-20 01:10:39.538  INFO 8644 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2017-04-20 01:10:39.622  INFO 8644 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
2017-04-20 01:10:39.629  INFO 8644 --- [           main] com.bookstore.BookstoreApplication       : Started BookstoreApplication in 5.211 seconds (JVM running for 5.915)
2017-04-20 01:10:47.623  INFO 8644 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring FrameworkServlet 'dispatcherServlet'
2017-04-20 01:10:47.623  INFO 8644 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization started
2017-04-20 01:10:47.647  INFO 8644 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization completed in 24 ms

控制台中没有显示错误。我曾经通过删除.m2文件夹并更新maven来解决同样的问题。但这次我几乎完成了所有事情(删除.m2,引用,清理,更改工作空间),但似乎没有任何工作。

请帮助我被困住

编辑:

微量

2017-04-20 03:07:28.683 DEBUG 3168 --- [nio-8080-exec-4] o.a.c.c.C.[.[.[/].[dispatcherServlet]    :  Disabling the response for futher output
2017-04-20 03:07:28.705 DEBUG 3168 --- [nio-8080-exec-5] o.a.c.authenticator.AuthenticatorBase    : Security checking request GET /favicon.ico
2017-04-20 03:07:28.705 DEBUG 3168 --- [nio-8080-exec-5] org.apache.catalina.realm.RealmBase      :   No applicable constraints defined
2017-04-20 03:07:28.705 DEBUG 3168 --- [nio-8080-exec-5] o.a.c.authenticator.AuthenticatorBase    :  Not subject to any constraint
2017-04-20 03:07:28.705 DEBUG 3168 --- [nio-8080-exec-5] o.apache.catalina.core.StandardWrapper   :   Returning non-STM instance
2017-04-20 03:07:28.706 DEBUG 3168 --- [nio-8080-exec-5] org.apache.tomcat.util.http.Parameters   : Set encoding to UTF-8
2017-04-20 03:07:28.706 DEBUG 3168 --- [nio-8080-exec-5] o.s.b.w.f.OrderedRequestContextFilter    : Bound request context to thread: org.apache.catalina.connector.RequestFacade@16acbde3
2017-04-20 03:07:28.706 TRACE 3168 --- [nio-8080-exec-5] o.s.web.servlet.DispatcherServlet        : Bound request context to thread: org.apache.catalina.connector.RequestFacade@16acbde3
2017-04-20 03:07:28.706 DEBUG 3168 --- [nio-8080-exec-5] o.s.web.servlet.DispatcherServlet        : DispatcherServlet with name 'dispatcherServlet' processing GET request for [/favicon.ico]
2017-04-20 03:07:28.706 TRACE 3168 --- [nio-8080-exec-5] o.s.web.servlet.DispatcherServlet        : Testing handler map [org.springframework.web.servlet.handler.SimpleUrlHandlerMapping@4c311da] in DispatcherServlet with name 'dispatcherServlet'
2017-04-20 03:07:28.706 DEBUG 3168 --- [nio-8080-exec-5] o.s.w.s.handler.SimpleUrlHandlerMapping  : Matching patterns for request [/favicon.ico] are [/**/favicon.ico]
2017-04-20 03:07:28.706 DEBUG 3168 --- [nio-8080-exec-5] o.s.w.s.handler.SimpleUrlHandlerMapping  : URI Template variables for request [/favicon.ico] are {}
2017-04-20 03:07:28.707 DEBUG 3168 --- [nio-8080-exec-5] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapping [/favicon.ico] to HandlerExecutionChain with handler [ResourceHttpRequestHandler [locations=[ServletContext resource [/], class path resource [META-INF/resources/], class path resource [resources/], class path resource [static/], class path resource [public/], class path resource []], resolvers=[org.springframework.web.servlet.resource.PathResourceResolver@bd1111a]]] and 1 interceptor
2017-04-20 03:07:28.707 TRACE 3168 --- [nio-8080-exec-5] o.s.web.servlet.DispatcherServlet        : Testing handler adapter [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter@22ca2b3]
2017-04-20 03:07:28.707 TRACE 3168 --- [nio-8080-exec-5] o.s.web.servlet.DispatcherServlet        : Testing handler adapter [org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter@4ab6bcb5]
2017-04-20 03:07:28.707 DEBUG 3168 --- [nio-8080-exec-5] o.s.web.servlet.DispatcherServlet        : Last-Modified value for [/favicon.ico] is: -1
2017-04-20 03:07:28.707 TRACE 3168 --- [nio-8080-exec-5] o.s.w.s.r.ResourceHttpRequestHandler     : Applying "invalid path" checks to path: favicon.ico
2017-04-20 03:07:28.707 TRACE 3168 --- [nio-8080-exec-5] o.s.w.s.resource.PathResourceResolver    : Resolving resource for request path "favicon.ico"
2017-04-20 03:07:28.707 TRACE 3168 --- [nio-8080-exec-5] o.s.w.s.resource.PathResourceResolver    : Checking location: ServletContext resource [/]
2017-04-20 03:07:28.707 TRACE 3168 --- [nio-8080-exec-5] o.s.w.s.resource.PathResourceResolver    : No match for location: ServletContext resource [/]
2017-04-20 03:07:28.707 TRACE 3168 --- [nio-8080-exec-5] o.s.w.s.resource.PathResourceResolver    : Checking location: class path resource [META-INF/resources/]
2017-04-20 03:07:28.708 TRACE 3168 --- [nio-8080-exec-5] o.s.w.s.resource.PathResourceResolver    : No match for location: class path resource [META-INF/resources/]
2017-04-20 03:07:28.708 TRACE 3168 --- [nio-8080-exec-5] o.s.w.s.resource.PathResourceResolver    : Checking location: class path resource [resources/]
2017-04-20 03:07:28.708 TRACE 3168 --- [nio-8080-exec-5] o.s.w.s.resource.PathResourceResolver    : No match for location: class path resource [resources/]
2017-04-20 03:07:28.708 TRACE 3168 --- [nio-8080-exec-5] o.s.w.s.resource.PathResourceResolver    : Checking location: class path resource [static/]
2017-04-20 03:07:28.709 TRACE 3168 --- [nio-8080-exec-5] o.s.w.s.resource.PathResourceResolver    : No match for location: class path resource [static/]
2017-04-20 03:07:28.709 TRACE 3168 --- [nio-8080-exec-5] o.s.w.s.resource.PathResourceResolver    : Checking location: class path resource [public/]
2017-04-20 03:07:28.709 TRACE 3168 --- [nio-8080-exec-5] o.s.w.s.resource.PathResourceResolver    : No match for location: class path resource [public/]
2017-04-20 03:07:28.709 TRACE 3168 --- [nio-8080-exec-5] o.s.w.s.resource.PathResourceResolver    : Checking location: class path resource []
2017-04-20 03:07:28.709 TRACE 3168 --- [nio-8080-exec-5] o.s.w.s.resource.PathResourceResolver    : Found match: class path resource [favicon.ico]
2017-04-20 03:07:28.710 TRACE 3168 --- [nio-8080-exec-5] o.s.w.s.r.ResourceHttpRequestHandler     : No media type found for class path resource [favicon.ico] - not sending a content-type header
2017-04-20 03:07:28.713 DEBUG 3168 --- [nio-8080-exec-5] o.s.web.servlet.DispatcherServlet        : Null ModelAndView returned to DispatcherServlet with name 'dispatcherServlet': assuming HandlerAdapter completed request handling
2017-04-20 03:07:28.713 TRACE 3168 --- [nio-8080-exec-5] o.s.web.servlet.DispatcherServlet        : Cleared thread-bound request context: org.apache.catalina.connector.RequestFacade@16acbde3
2017-04-20 03:07:28.714 DEBUG 3168 --- [nio-8080-exec-5] o.s.web.servlet.DispatcherServlet        : Successfully completed request
2017-04-20 03:07:28.714 TRACE 3168 --- [nio-8080-exec-5] ationConfigEmbeddedWebApplicationContext : Publishing event in org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@dd8ba08: ServletRequestHandledEvent: url=[/favicon.ico]; client=[0:0:0:0:0:0:0:1]; method=[GET]; servlet=[dispatcherServlet]; session=[null]; user=[null]; time=[8ms]; status=[OK]

0 个答案:

没有答案