这个是干什么的 ? idea的设置

我在pom文件里添加坐标 , 默认scope 不就是provided吗? 但是必须勾选这个,才不会报 Caused by: java.lang.ClassNotFoundException: javax.servlet.ServletContext 错误。

 <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>4.0.1</version>
 </dependency>

img

provided scope 特性如下:
This is much like compile, but indicates you expect the JDK or a container to provide the dependency at runtime. For example, when building a web application for the Java Enterprise Edition, you would set the dependency on the Servlet API and related Java EE APIs to scope provided because the web container provides those classes. A dependency with this scope is added to the classpath used for compilation and test, but not the runtime classpath. It is not transitive.

意思是,把你要把provided 的依赖加进去。