• 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版本对应

    1. web-app 3.0
    2. jdk版本1.6以上,开始支持jsp-config配置
    3. <web-app
    4. version="3.0"
    5. xmlns="http://java.sun.com/xml/ns/javaee"
    6. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    7. xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
    8. </web-app>
    9. web-app 3.1
    10. jdk版本1.7以上
    11. <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
    12. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    13. xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
    14. version="3.1"> </web-app>
    15. web-app 4.0约束
    16. jdk版本1.8以上
    17. <?xml version="1.0" encoding="UTF-8"?>
    18. <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
    19. http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" version="4.0">
    20. <display-name>Archetype Created Web Application</display-name>
    21. </web-app>

    5、导入sevlet 依赖

    1. <!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
    2. <dependency>
    3. <groupId>javax.servlet</groupId>
    4. <artifactId>javax.servlet-api</artifactId>
    5. <version>3.1.0</version>
    6. <scope>provided</scope>
    7. </dependency>

     

  • 相关阅读:
    如何解密Allatori 混淆的字符串 Java ALLATORIxDEMO
    Java获取数组最大值、Java8的Arrays.sort()原理
    [动态规划] 0-1背包问题和完全背包问题
    噪音人声识别接口
    一天吃透Java面试题
    [StartingPoint][Tier1]Crocodile
    山区自建房BCD浪涌保护器接线方案(自建房用电防雷)
    java基于SpringBoot+Vue+nodejs的协同过滤算法商品推荐系统 element
    SpringBoot + Vue实现博文上传+展示+博文列表
    【pwn】2022 羊城杯 fakeNoOutput
  • 原文地址:https://blog.csdn.net/jingde528/article/details/126950218