完美解決!!!
首先,在當前專案中創建一個maven的module.
然后在maven專案中的pom.xml檔案中匯入jar包,代碼如下:
<!--打包方式-->
<packaging>war</packaging>
<!-- 匯入需要使用的jar包 -->
<dependencies>
<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.servlet.jsp/javax.servlet.jsp-api -->
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>javax.servlet.jsp-api</artifactId>
<version>2.3.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.servlet/jstl -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/taglibs/standard -->
<dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>1.1.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.15</version>
</dependency>
</dependencies>
<!-- 解決靜態資源匯出失敗問題 -->
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<excludes>
<exclude>/*.properties</exclude>
<exclude>/*.xml</exclude>
</excludes>
<filtering>true</filtering>
</resource>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>/*.properties</exclude>
<exclude>/*.xml</exclude>
</excludes>
<filtering>true</filtering>
</resource>
</resources>
</build>
插入進去后,保存,并點擊右側maven中的

等待右下角進度條加載完畢后,
進入之后

將maven專案匯入的jar包匯入進需要的專案,這樣回去新建的時候就有Servlet了!!!
PS:當你每次關閉專案重新進入的時候,都需要設定一個東西

在這里打上勾,就又一樣了
如果這篇文章解決了你的問題的話,還請給我點個贊吧!!
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/282566.html
標籤:其他
上一篇:golang基于UDP完成
