使用maven创建springBoot

我们在使用maven创建一个web项目时,创建成功后index.jsp页面总会报错,这是因为缺少

The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path

使用maven创建springBoot

使用maven创建springBoot

以前我们的解决方法是,在pom.xml配置文件中加入jaee包

  <dependency>
      <groupId>javax</groupId>
      <artifactId>javaee-api</artifactId>
      <version>7.0</version>
      <scope>compile</scope>

    </dependency>

加入成功以后,项目名又会报错,

使用maven创建springBoot

原因如下:

使用maven创建springBoot

于是我们需要做各种设置(见JavaServer Faces 2.2 requires Dynamic Web Module 2.5 or newer),

第一种:现在我们只需要在pom.xml文件中加入:

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

</dependency>

第二种:对于在springBoot中,我们可以加入以下依赖包:

<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.3.7.RELEASE</version>
</dependency>
<!-- 连接池 -->
<dependency>
<groupId>com.jolbox</groupId>
<artifactId>bonecp-spring</artifactId>
<version>0.8.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

</dependencies>

然后update project就行