Spring tool suite4新建maven web项目
Spring tool suite4新建maven web项目
·
Spring tool suite4运行环境需要jdk 以上,试验环境:jdk-13.0.2 + Spring Tool Suite 4.6.1.RELEASE
1、new -> maven project
如果没有以上菜单,可以从 window -> perspective -> customize perspective -> shortcuts添加
如上出现空白,且很久没有出来内容时,可以在maven中运行 archetype:generate来下载依赖,然后重启eclipse,步骤:
a)添加环境变量:MAVEN_HOME
b)更改path,写入 %MAVEN_HOME%\bin\
c)打开cmd,在对话框输入【 mvn archetype:generate】,选择10是web相关的依赖,回车等待下载依赖文件
2、右击项目->properties->Java Build Path -> order and export选择如下,使项目生成相应的文件包
3、右击项目 -> properties -> project facets
将web对应的版本更改成与jdk对应的版本(先取消选择 -> apply ->更换版本)
4、web.xml中默认的版本是2.3,更改使其与所选的web版本对应
web-app 3.0
jdk版本1.6以上,开始支持jsp-config配置
<web-app
version="3.0"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
</web-app>
web-app 3.1
jdk版本1.7以上
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1"> </web-app>
web-app 4.0约束
jdk版本1.8以上
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" version="4.0">
<display-name>Archetype Created Web Application</display-name>
</web-app>
5、导入sevlet 依赖
<!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
更多推荐
已为社区贡献2条内容
所有评论(0)