美文网首页
3012 Meven创建Web项目

3012 Meven创建Web项目

作者: 风影星源 | 来源:发表于2020-08-14 09:42 被阅读0次

1、pom.xml的修改

    <!-- 设置项目类型  jar  war -->
    <packaging>war</packaging>

    <dependencies>
        <!-- web项目的编译环境 -->
        <dependency>
            <!-- jstl 支持 -->
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <!-- servlet编译环境 -->
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.1.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <!-- jsp编译环境 -->
            <groupId>javax.servlet</groupId>
            <artifactId>jsp-api</artifactId>
            <version>2.0</version>
            <scope>provided</scope>
        </dependency>

        <!-- 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/mysql/mysql-connector-java -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.47</version>
            <!--<scope>runtime</scope>-->
        </dependency>
    </dependencies>

2、webapp路径的创建

2.1 路径位置

路径.png

2.2 web.xml

<?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">
    <!-- 这是一个空白的web.xml文件模板 -->

</web-app>

3、添加Tomcat

tomcat1.png tomcat2.png

相关文章

网友评论

      本文标题:3012 Meven创建Web项目

      本文链接:https://www.haomeiwen.com/subject/irsidktx.html