完美解决!!!
首先,在当前项目中创建一个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:当你每次关闭项目重新进入的时候,都需要设置一个东西
在这里打上勾,就又一样了
如果这篇文章解决了你的问题的话,还请给我点个赞吧!!