zoukankan      html  css  js  c++  java
  • 用maven创建web项目

    (1) 创建一个Maven Project

    File》》New》》Other

    (2)这时index.jsp页面报错 ,javax.servlet.http.HttpServlet was not found on the java build path    

            

         解决方法 :在pom.xml中加入servlet

    进入http://www.mvnrepository.com搜索 

    选择一个版本

    复制代码

    <dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>servlet-api</artifactId>
    <version>3.0.1</version>
    </dependency>

    pom.xml的代码如下

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.wxx.mytest</groupId>
    <artifactId>mytest</artifactId>
    <packaging>war</packaging>
    <version>0.0.1-SNAPSHOT</version>
    <name>mytest Maven Webapp</name>
    <url>http://maven.apache.org</url>
    <dependencies>
    <dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>

    <!--改成4.10-->
    <version>4.10</version>
    <scope>test</scope>
    </dependency>
    <dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>javax.servlet-api</artifactId>
    <version>3.0.1</version>
    <!-- 只在编译和测试时运行 -->
    <scope>provided</scope>
    </dependency>
    </dependencies>
    <build>
    <finalName>mytest</finalName>
    </build>
    </project>

     保存后错误应该就没有了

    (3)创建maven的其它目录。最后在Java Resources中应该有这些目录,,但是因为我直接添加Source Folder是失败的,所以我选择另一种方法添加这些目录

    先点击Window》》show view》》Other    视图中对应出现这个

     接下来根据下面图片中目录创建文件夹

    返回Project Explorer刷新

    (4)之后右击项目名称点击Properties添加动态web

    再右击项目名称点击Properties,将删除source中多余数据,因为发布时不需要发布test中的东西

    (4)因为用的是tomcat,之前也配置过直接运行 就好了

  • 相关阅读:
    IOS UITextView自适应高度
    listview、gradview滚动到最后时,滑动至顶部
    iOS- 详解文本属性Attributes
    initializer element is not a compile-time constant
    国内外例子源码地址
    iOS开发所有KeyboardType与图片对应展示
    去掉xcode编译warning:ld: warning: directory not found for option '-L
    IQKeyboardManager使用方法
    Mysql 内部默认排序
    Hadoop 集群的一些问题
  • 原文地址:https://www.cnblogs.com/wangjiaxiaoxi/p/6502567.html
Copyright © 2011-2022 走看看