如何搭建maven项目以及解决一些其中一些小问题
有一天听到朋友在聊如何新建聚会工程的事,其中听到了一些不同的说法,对他们的说法我感到好奇,所以带着想法去搭建一下,虽然搭建是很简单的事,但是还是想搞一下。这里不得不说使用eclipse搭建maven项目是真的鸡肋。

一、搭建项目
1、创建maven项目
NEW ------> maven项目
如何搭建maven项目以及解决web.xml is missing and <failOnMissingWebXml> is set to true问题和去除异常 随笔 第1张

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。

Next
groupId和artifactId:
GroupID 是项目组织唯一的标识符,实际对应JAVA的包的结构,是main目录里java的目录结构。
ArtifactID是项目的唯一的标识符,实际对应项目的名称,就是项目根目录的名称。
parent工程:
如何搭建maven项目以及解决web.xml is missing and <failOnMissingWebXml> is set to true问题和去除异常 随笔 第2张

2、新建common,打包方式jar
如何搭建maven项目以及解决web.xml is missing and <failOnMissingWebXml> is set to true问题和去除异常 随笔 第3张

如何搭建maven项目以及解决web.xml is missing and <failOnMissingWebXml> is set to true问题和去除异常 随笔 第4张

3、新建pojo, 打包方式jar
如何搭建maven项目以及解决web.xml is missing and <failOnMissingWebXml> is set to true问题和去除异常 随笔 第5张

Pojo依赖common,加上依赖
如何搭建maven项目以及解决web.xml is missing and <failOnMissingWebXml> is set to true问题和去除异常 随笔 第6张

如何搭建maven项目以及解决web.xml is missing and <failOnMissingWebXml> is set to true问题和去除异常 随笔 第7张

如何搭建maven项目以及解决web.xml is missing and <failOnMissingWebXml> is set to true问题和去除异常 随笔 第8张

新建mapper,jar
如何搭建maven项目以及解决web.xml is missing and <failOnMissingWebXml> is set to true问题和去除异常 随笔 第9张

加上pojo依赖
如何搭建maven项目以及解决web.xml is missing and <failOnMissingWebXml> is set to true问题和去除异常 随笔 第10张

如何搭建maven项目以及解决web.xml is missing and <failOnMissingWebXml> is set to true问题和去除异常 随笔 第11张

如何搭建maven项目以及解决web.xml is missing and <failOnMissingWebXml> is set to true问题和去除异常 随笔 第12张

新建service,jar
如何搭建maven项目以及解决web.xml is missing and <failOnMissingWebXml> is set to true问题和去除异常 随笔 第13张

加依赖mapper

如何搭建maven项目以及解决web.xml is missing and <failOnMissingWebXml> is set to true问题和去除异常 随笔 第14张

如何搭建maven项目以及解决web.xml is missing and <failOnMissingWebXml> is set to true问题和去除异常 随笔 第15张

新建web,war包

如何搭建maven项目以及解决web.xml is missing and <failOnMissingWebXml> is set to true问题和去除异常 随笔 第16张

如何搭建maven项目以及解决web.xml is missing and <failOnMissingWebXml> is set to true问题和去除异常 随笔 第17张

我们发现出现红叉和异常,我们来解决一下
如何搭建maven项目以及解决web.xml is missing and <failOnMissingWebXml> is set to true问题和去除异常 随笔 第18张

出现错误:

Description Resource    Path    Location    Type
web.xml is missing and <failOnMissingWebXml> is set to true pom.xml /zsl-maven-test-web line 9  Maven Java EE Configuration Problem

原因是它是个web,却找不到web.xml,有两种方案:
1、(生成web.xml——>部署运行时文件路径)
在src/main/webapp/WEB-INF目录下生成web.xml文件;
2、在pom.xml中加入插件:

<build>
        <plugins>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.6</version>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>

        </plugins>

    </build>

现在编译不报错了,但是有很多异常
如何搭建maven项目以及解决web.xml is missing and <failOnMissingWebXml> is set to true问题和去除异常 随笔 第19张

如何搭建maven项目以及解决web.xml is missing and <failOnMissingWebXml> is set to true问题和去除异常 随笔 第20张

解决方案:改jre环境:
Build Path 、configure Build Path

如何搭建maven项目以及解决web.xml is missing and <failOnMissingWebXml> is set to true问题和去除异常 随笔 第21张

如何搭建maven项目以及解决web.xml is missing and <failOnMissingWebXml> is set to true问题和去除异常 随笔 第22张

如何搭建maven项目以及解决web.xml is missing and <failOnMissingWebXml> is set to true问题和去除异常 随笔 第23张

如何搭建maven项目以及解决web.xml is missing and <failOnMissingWebXml> is set to true问题和去除异常 随笔 第24张

现在没异常了

如何搭建maven项目以及解决web.xml is missing and <failOnMissingWebXml> is set to true问题和去除异常 随笔 第25张

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄