Spring引导无法在1.5.8版本

时间:2017-10-30 04:21:43

标签: spring-boot

环境:

  1. STS-3.9.0.RELEASE
  2. Java版本:1.7
  3. Spring Starter Project,web
  4. 我有一个弹簧启动项目,1.4.2版本可以正常工作,但1.5.8版本没有。当我更改为1.5.8时,它会停止编译JSP并按原样打印页面。

    以下是我的文件:

    的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.educo</groupId>
    <artifactId>sprboot</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>
    
    <name>sprboot</name>
    <description>Event tracker project</description>
    
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.4.2.RELEASE</version>
    </parent>
    
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.7</java.version>
    </properties>
    
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
    
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
        </dependency>
    
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
        </dependency>
    
        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-jasper</artifactId>
            <scope>provided</scope>
        </dependency>
    
        <dependency>
            <groupId>org.eclipse.jdt.core.compiler</groupId>
            <artifactId>ecj</artifactId>
            <version>4.6.1</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
    
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>    
    </project>
    

    src / main / java,com.educo.Application.java

    package com.educo;
    
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.boot.builder.SpringApplicationBuilder;
    import org.springframework.boot.web.support.SpringBootServletInitializer;
    
    @SpringBootApplication
    public class Application extends SpringBootServletInitializer{
    
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(Application.class);
    }
    
    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
    }
    

    src / main / resources,application.properties

    spring.mvc.view.prefix: /WEB-INF/jsp/
    spring.mvc.view.suffix: .jsp
    
    welcome.message: Hello
    

    src / main / java,com.educo.controller

    package com.educo.controller;
    
    import org.springframework.stereotype.Controller;
    import org.springframework.ui.ModelMap;
    import org.springframework.web.bind.annotation.PathVariable;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RequestParam;
    import org.springframework.web.bind.annotation.ResponseBody;
    
    @Controller
    public class TestController {
    
    @RequestMapping("/")
    public String index() {
        return "index";
    }
    
    @RequestMapping("/body")
    @ResponseBody
    public String body() {
        System.out.println("there");
        return "Hello world!";
    }
    
    // /param?name=ashutosh
    @RequestMapping("/param")
    @ResponseBody
    public String params(@RequestParam String name) {
        return "Hello " + name;
    }
    
    // /path/ashutosh
    @RequestMapping("/path/{name}")
    @ResponseBody
    public String paths(@PathVariable String name) {
        return "Hello " + name;
    }
    
    // /path-view/ashutosh
    @RequestMapping("/path-view/{name}")
    public String pathView(@PathVariable String name, ModelMap map) {
        map.addAttribute("name", name);
        return "path-view";
    }
    }
    

    src / main / webapp,/ WEB-INF / jsp / index.jsp

    <b>Welcome</b> to my website
    

    src / main / webapp,/ WEB-INF / jsp / path-view.jsp

    <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false"
    %>
    
    Hello ${name} by path view
    

    更改为:

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.8.RELEASE</version>
    </parent>
    

    我收到错误:

    Whitelabel Error Page
    
    This application has no explicit mapping for /error, so you are seeing this as a fallback.
    
    Sun Oct 29 23:58:06 EDT 2017
    There was an unexpected error (type=Not Found, status=404).
    No message available
    

    在tomcat控制台上没有打印错误。 我试图读取1.5.8的更改日志,但在此找不到任何内容。我在这里失踪了什么?

0 个答案:

没有答案