基于project工程,一个工程里面包含多个模块(module)

一,配置Maven

(1)file-->Other Settings-->Setting For New Projects..

(2)配置maven文件路径选中Override:覆盖,设置好后点击Apply-->Ok

二,创建Maven Web项目

(1)file-->New-->ProJect..

 (2)Maven-->Create From archetype打对勾选择maven-archetype-webapp

(3) New Porject-->填写好后Finish

(4)打开创建好的工程依次点击src-->main-->New-->Directory-->

-->双击java

 

 依次类推-->双击resources

文件目录

 点击src-->New-->Directory-->你会发现有test和resources也一起拿到项目中

(5)配置jdk1.8

pom.xml中<build></build>标签给上一下代码段

<plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.7.0</version>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
          <encoding>UTF-8</encoding>
        </configuration>
      </plugin>
</plugins>

注意:properties标签需要修改版本号 

 

(6)配置web3.0,找到web.xml修改web-app

<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns="http://java.sun.com/xml/ns/javaee"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
         id="WebApp_ID" version="3.0">
  <display-name>Archetype Created Web Application</display-name>
</web-app>

(7)Maven的引入依赖

到Maven官网粘贴引入依赖

下页网址:https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api/4.0.1

 把粘贴的代码放到pomx.xml中properties和dependencies里,如图:

以下完毕后Ctrl+S保存pom.xml会自动下载jar包(也有可能是手动执行)

注意注意注意:着整个环节需要保证网络畅通,不然下载失败!!!

 进度条走完以后查看Extermal Libraries下已下载的jar包和它的依赖包啦

 

Waven配置成功,创建Maven Web项目

实有不足望请原谅

Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐