从Spring Boot 2.0.0到2.2.1关于javax.servlet。*库依赖的区别是什么

时间:2019-12-15 12:23:02

标签: spring-boot spring-mvc

我正在用JSP进行Spring boot mvc项目。 当我使用2.0.0.RELEASE版本时,一切正常! 这是我的pom.xml的一部分:

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

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-jasper</artifactId>
            <scope>provided</scope>
        </dependency>
        ...

这是我的入门班:

package com.test;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;

@SpringBootApplication
public class TestApplication extends SpringBootServletInitializer {
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(TestApplication .class);
    }

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

但是当我将spring-boot-starter-parent更改为2.2.1.RELEASE时 我的启动类中的Eclipse报告错误:

Multiple markers at this line
    - The type javax.servlet.ServletContext cannot be resolved. It is indirectly referenced from 
     required .class files
    - The type javax.servlet.ServletException cannot be resolved. It is indirectly referenced from 
     required .class files

我知道我可以添加一些其他依赖项来解决此问题,但是我不想这样做。 有人可以指导我了解春季靴子版本的不同吗?预先感谢!

0 个答案:

没有答案