索引:

目录索引

参看代码 GitHub:

solution/pom.xml

pojo/pom.xml

mapper/pom.xml

common/pom.xml

service/pom.xml

console/pom.xml

web/pom.xml

webapi/pom.xml

webservice/pom.xml

一、Intelij IDEA 中构建 maven 项目及模块

   1.新建 maven 项目,在IDE中的菜单位置

  2.项目中新建模块在IDE中的菜单位置

  3.整个项目的结构

二、Maven 模块及模块关系要点讲解

  1.solution/pom.xml

    <groupId>lm.solution</groupId> 

    <artifactId>solution</artifactId>    

    <version>1.0-SNAPSHOT</version>    

    讲解:

      groupId :模块项目归属组织名称

      artifactId:项目内模块名称

      version:模块的版本号

      这三个属性唯一的标识了一个模块,也被称为 maven 坐标。

    <modules>

      <module>webapi</module>

      ... ...

    </modules>

    讲解:

      因为 solution 这个模块是做为项目父模块存在的,在 modules 标签内就指明了该模块都包含哪些子模块:

      webapi、web、common、service、mapper、pojo、console、webservice。

    <packaging>pom</packaging>

    讲解:    

      因为 solution 模块将包含多个子模块,所以这里的打包方式选择 pom 值。

    <properties>

      <spring.version>4.3.13.RELEASE</spring.version>

      ... ...

    </properties>

    讲解:  

      在父模块中定义的 properties maven 属性变量,除了在本模块中可直接引用外,在所有的子模块中也可以直接被引用,

      也就是说在子模块中就可以不必在重新定义 maven的属性变量了,如 spring.version 这个属性变量,在所有模块及子模块中

      可以被直接使用 ${spring.version} 。

    <dependencies> 

       <dependency>

        <groupId>junit</groupId>

        <artifactId>junit</artifactId>

        ... ...

      </dependency>

      ... ...

    </dependencies>

    讲解:  

      在父模块中定义的类库依赖,除了在父模块中会做引用以外,在所有子模块中也都会做自动的引用,

      所以在子模块中就不必添加 dependencies 中的依赖了,如 junit 这个第三方类库,在子模块中 maven

      会自动继承父模块的 junit 依赖,子模块中就不必再添加 junit 的类库依赖了。

    <dependencyManagement>

      <dependencies>

        <dependency>

          <groupId>org.mybatis</groupId>

          <artifactId>mybatis</artifactId>

          <version>${mybatis.version}</version>

        </dependency>

        ... ...

      </dependencies>

    </dependencyManagement>

    讲解:  

      有的类库依赖,在部分子模块中需要,在部分子模块中不需要,此时,就可将依赖关系放到此节点中,

      例如:mybatis 这个第三方 orm 库,在 pojo(仅是映射关系的实体层) 子模块中没有依赖,而在 mapper(orm 存储仓层) 这个

      子模块中就是关键依赖。

    <build>

      <plugins>

        <plugin>

          <groupId>org.apache.maven.plugins</groupId>

          <artifactId>maven-compiler-plugin</artifactId>

          ... ...

        </plugin>

      </plugins>

      <pluginManagement>

        <plugins>

          <plugin>

            <groupId>org.apache.tomcat.maven</groupId>

            <artifactId>tomcat8-maven-plugin</artifactId>

            ... ...

          </plugin>

        </plugins>

      </pluginManagement>

    </build>

    讲解: 

      这里 plugins 与 pluginManagement 可参看上面讲解到的 dependencies 与 dependencyManagement 的作用,他们作用

      类似,因为每个模块都需要 maven-compiler-plugin 编译插件,所以直接将其放到父模块的 plugins 标签内,而 tomcat8-maven-plugin

      插件只有 web 子模块需要,所以将其放到 pluginManagement 标签中。

     solution/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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <groupId>lm.solution</groupId>
<artifactId>solution</artifactId>
<version>1.0-SNAPSHOT</version>
<modules>
<module>webapi</module>
<module>web</module>
<module>common</module>
<module>service</module>
<module>mapper</module>
<module>pojo</module>
<module>console</module>
<module>webservice</module>
</modules>
<packaging>pom</packaging> <name>solution</name>
<url>http://maven.apache.org</url> <properties>
<!--编译字符集-->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- spring -->
<spring.version>4.3.13.RELEASE</spring.version>
<!-- log4j -->
<slf4j.version>1.7.7</slf4j.version>
<log4j.version>1.2.17</log4j.version>
<!-- jackson -->
<jackson.version>2.9.4</jackson.version>
<!-- junit -->
<junit.version>4.12</junit.version>
<!-- aspectj -->
<aspectj.version>1.8.13</aspectj.version>
<!-- cglib -->
<cglib.version>3.1</cglib.version>
<!-- mybatis -->
<mybatis.version>3.4.5</mybatis.version>
<!-- mybatis-spring -->
<mybatisSpring.version>1.3.1</mybatisSpring.version>
<!--mysql-connector-->
<mysql.version>5.1.34</mysql.version>
<!--druid-->
<druid.version>1.0.5</druid.version>
<!--javax.servlet-->
<javaxServlet.version>3.0.1</javaxServlet.version>
<!--jsp-api-->
<jspApi.version>2.2</jspApi.version>
<!--jstl-->
<jstl.version>1.2</jstl.version>
<!--json-lib-->
<jsonLib.version>2.1</jsonLib.version>
<!--jackson old-->
<jacksonOld.version>1.9.13</jacksonOld.version>
<!--dom4j-->
<dom4j.version>1.6.1</dom4j.version>
<!--ehcache core-->
<ehcacheCore.version>2.6.9</ehcacheCore.version>
<!--ehcache web-->
<ehcacheWeb.version>2.0.4</ehcacheWeb.version>
<!--commons-fileupload-->
<commonsFileupload.version>1.3.1</commonsFileupload.version>
<!--commons-io-->
<commonsIo.version>2.4</commonsIo.version>
<!--commons-codec-->
<commonsCodec.version>1.9</commonsCodec.version>
<!--commons-collections4-->
<commonsCollections4.version>4.0</commonsCollections4.version>
<!--commons-beanutils-->
<commonsBeanutils.version>1.7.0</commonsBeanutils.version>
<!--freemarker-->
<freemarker.version>2.3.19</freemarker.version>
<!-- poi poi-ooxml -->
<poi.version>3.9</poi.version>
<!--org.apache.httpcomponents-->
<httpcore.version>4.4.8</httpcore.version>
<httpclient.version>4.5.4</httpclient.version>
<!-- jaxws-rt -->
<jaxwsRt.version>2.3.0</jaxwsRt.version>
<!-- jedis -->
<jedis.version>2.9.0</jedis.version>
<!-- rabbitmq -->
<amqpClient.version>5.1.2</amqpClient.version>
<!--fastjson-->
<fastjson.version>1.2.46</fastjson.version>
<!-- jsr250 -->
<jsr250.version>1.0</jsr250.version>
</properties> <dependencies>
<!--单元测试依赖 -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>RELEASE</version>
<!--test 说明这个包的存活是在test周期,也就是发布时将不包含这个jar包-->
<scope>test</scope>
</dependency>
<!--spring单元测试依赖 -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
<scope>test</scope>
</dependency>
<!-- spring -->
<dependency>
<groupId>org.springframework</groupId>
<!-- 因依赖 会自动引入 spring-aop spring-beans spring-core spring-expression 四个包 -->
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency>
<!-- aspectj AOP -->
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>${aspectj.version}</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>${aspectj.version}</version>
</dependency>
<!-- 映入JSON jackson -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
<version>${jackson.version}</version>
</dependency>
<!-- 日志文件管理包 -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j.version}</version>
</dependency>
</dependencies> <dependencyManagement>
<dependencies>
<!--spring web-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<!--cglib-->
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>${cglib.version}</version>
</dependency>
<!-- mybatis -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>${mybatis.version}</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>${mybatisSpring.version}</version>
</dependency>
<!-- Mysql数据库驱动包 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.version}</version>
</dependency>
<!-- connection pool -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>${druid.version}</version>
<!--<scope>runtime</scope>-->
</dependency>
<!--servlet-->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>${javaxServlet.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>${jspApi.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>${jstl.version}</version>
</dependency>
<!-- 映入JSON lib -->
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<version>${jsonLib.version}</version>
<classifier>jdk15</classifier>
</dependency>
<!-- jackson old -->
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-core-asl</artifactId>
<version>${jacksonOld.version}</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>${jacksonOld.version}</version>
</dependency>
<!-- 用dom4j解析xml文件 -->
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>${dom4j.version}</version>
</dependency>
<!-- ehcache -->
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache-core</artifactId>
<version>${ehcacheCore.version}</version>
</dependency>
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache-web</artifactId>
<version>${ehcacheWeb.version}</version>
</dependency>
<!-- 上传组件包 -->
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>${commonsFileupload.version}</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>${commonsIo.version}</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>${commonsCodec.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
<version>${commonsCollections4.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.3.2</version>
</dependency>
<!-- commons-beanutils -->
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>${commonsBeanutils.version}</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- freemarker -->
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>${freemarker.version}</version>
</dependency>
<!-- poi -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>${poi.version}</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>${poi.version}</version>
</dependency>
<!-- org.apache.httpcomponents -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>${httpcore.version}</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>${httpclient.version}</version>
</dependency>
<!-- com.sun.xml.ws/jaxws-rt -->
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-rt</artifactId>
<version>${jaxwsRt.version}</version>
</dependency>
<!-- redis.clients/jedis -->
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>${jedis.version}</version>
</dependency>
<!-- com.rabbitmq/amqp-client -->
<dependency>
<groupId>com.rabbitmq</groupId>
<artifactId>amqp-client</artifactId>
<version>${amqpClient.version}</version>
</dependency>
<!-- com.alibaba/fastjson -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>${fastjson.version}</version>
</dependency>
<!-- javax.annotation/jsr250-api -->
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>jsr250-api</artifactId>
<version>${jsr250.version}</version>
</dependency>
</dependencies>
</dependencyManagement> <build>
<plugins>
<!-- java编译插件 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins> <pluginManagement>
<plugins>
<!-- 配置Tomcat插件 -->
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat8-maven-plugin</artifactId>
<version>3.0-r1756463</version>
</plugin>
</plugins>
</pluginManagement>
</build> </project>

  2.pojo/pom.xml

    这个模块是做为实体层的。

    重复内容不在讲解,参考上文的说明。

    <parent>

      <artifactId>solution</artifactId>

      <groupId>lm.solution</groupId>

      ... ...

    </parent>

    讲解:

      因为 pojo 模块是 solution 模块的子模块,所以要在 parent 标签内指明父模块是 solution 模块的坐标。

    <packaging>jar</packaging>

    讲解:

      因为这里 pojo 模块是做为其它模块依赖的类库使用的,所以打包方式为 jar 值。

    pojo/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/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>solution</artifactId>
<groupId>lm.solution</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion> <groupId>lm.solution</groupId>
<artifactId>pojo</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging> <name>pojo</name>
<url>http://maven.apache.org</url> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> <dependencies>
<!-- Module --> <!-- Libary --> </dependencies>
</project>

  3.mapper/pom.xml

    这个模块是做为存储仓层的。

    重复内容不在讲解,参考上文的说明。

    <dependencies>

      <dependency>

        <groupId>lm.solution</groupId>

        <artifactId>pojo</artifactId>

        <version>1.0-SNAPSHOT</version>

      </dependency>

      ... ... 

      <dependency>

        <groupId>org.mybatis</groupId>

        <artifactId>mybatis</artifactId>

      </dependency>

      ... ...

    </dependencies>

    讲解:

      因为 mapper 模块依赖 pojo 模块,所以这里引入 pojo 的依赖坐标,

      又由于该模块需要第三方mybatis类库,所以 这里引入mybatis 的 maven 坐标,

      上文中 solution 父模块 已经在  dependencyManagement 指明了,所以这里就不用再指明 version 了。

    mapper/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/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>solution</artifactId>
<groupId>lm.solution</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion> <groupId>lm.solution</groupId>
<artifactId>mapper</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging> <name>mapper</name>
<url>http://maven.apache.org</url> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> <dependencies>
<!--Module-->
<dependency>
<groupId>lm.solution</groupId>
<artifactId>pojo</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency> <!--Libary-->
<dependency><!-- mybatis核心包 -->
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
</dependency>
<dependency><!-- Mysql数据库驱动包 -->
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency><!-- connection pool -->
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<scope>runtime</scope>
</dependency>
</dependencies>
</project>

  4.common/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/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>solution</artifactId>
<groupId>lm.solution</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion> <groupId>lm.solution</groupId>
<artifactId>common</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging> <name>common</name>
<url>http://maven.apache.org</url> <dependencies>
<!--Module-->
<dependency>
<groupId>lm.solution</groupId>
<artifactId>pojo</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency> <!--Libary-->
<!--spring web-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
</dependency>
<!-- poi -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
</dependency>
<!-- poi-ooxml -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
</dependency>
<!--servlet-->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
<!-- org.apache.httpcomponents -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>
<!--Commons-->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
</dependency>
<!-- redis.clients/jedis -->
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
</dependency>
<!-- com.rabbitmq/amqp-client -->
<dependency>
<groupId>com.rabbitmq</groupId>
<artifactId>amqp-client</artifactId>
</dependency>
</dependencies>
</project>

  5.service/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/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>solution</artifactId>
<groupId>lm.solution</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion> <groupId>lm.solution</groupId>
<artifactId>service</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging> <name>service</name>
<url>http://maven.apache.org</url> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> <dependencies>
<!--Module-->
<dependency>
<groupId>lm.solution</groupId>
<artifactId>mapper</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency> <!--Libary--> </dependencies>
</project>

  6.console/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/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>solution</artifactId>
<groupId>lm.solution</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion> <groupId>lm.solution</groupId>
<artifactId>console</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging> <name>console</name>
<url>http://maven.apache.org</url> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> <dependencies>
<!-- Module -->
<dependency>
<groupId>lm.solution</groupId>
<artifactId>pojo</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>lm.solution</groupId>
<artifactId>common</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>lm.solution</groupId>
<artifactId>service</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency> <!-- Libary -->
<!-- jackson old -->
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-core-asl</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
</dependency>
<dependency>
<groupId>com.rabbitmq</groupId>
<artifactId>amqp-client</artifactId>
</dependency>
<!-- com.alibaba/fastjson -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
</dependency>
<!-- commons-io -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
<!-- javax.annotation/jsr250-api -->
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>jsr250-api</artifactId>
</dependency>
<!-- javax.servlet-api -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
</dependency> <!-- other -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>4.3.13.RELEASE</version>
</dependency>
</dependencies> </project>

  7.web/pom.xml

    这个模块是做为 web 站点的。

    重复内容不在讲解,参考上文的说明。

    <packaging>war</packaging>

    讲解:

      因为这模块在编译后是部署到 tomcat  容器的,所以这里采用的打包方式是 war 值。

    web/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">
<parent>
<artifactId>solution</artifactId>
<groupId>lm.solution</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>lm.solution</groupId>
<artifactId>web</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>web Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<!--Module-->
<dependency>
<groupId>lm.solution</groupId>
<artifactId>service</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>lm.solution</groupId>
<artifactId>common</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency> <!--Libary-->
<!--spring mvc-->
<dependency>
<groupId>org.springframework</groupId>
<!--引入该包后,maven 会自动解析依赖,引入 spring-web 等包。-->
<artifactId>spring-webmvc</artifactId>
</dependency>
<!--cglib-->
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
</dependency>
<!-- mybatis核心包 -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
</dependency>
<!--mybatis spring 插件 -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
</dependency>
<!-- Mysql数据库驱动包 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<!-- connection pool -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<!--<scope>runtime</scope>-->
</dependency>
<!--servlet-->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
<!-- 映入JSON lib -->
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<classifier>jdk15</classifier>
</dependency>
<!-- 用dom4j解析xml文件 -->
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
</dependency>
<!-- ehcache -->
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache-core</artifactId>
</dependency>
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache-web</artifactId>
</dependency>
<!-- 上传组件包 -->
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
<!-- common others -->
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<!-- commons-beanutils -->
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- freemarker -->
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
</dependency>
<!-- org.apache.httpcomponents -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>
<!-- redis.clients/jedis -->
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
</dependency>
<!-- com.rabbitmq/amqp-client -->
<dependency>
<groupId>com.rabbitmq</groupId>
<artifactId>amqp-client</artifactId>
</dependency>
<!-- com.alibaba/fastjson -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
</dependency>
</dependencies>
<build>
<finalName>web</finalName> <plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat8-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

  8.webapi/pom.xml

    这个模块是做为 Restful API 站点的。

    重复内容不在讲解,参考上文的说明。

 <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"> <parent>
<artifactId>solution</artifactId>
<groupId>lm.solution</groupId>
<version>1.0-SNAPSHOT</version>
</parent> <modelVersion>4.0.0</modelVersion>
<groupId>lm.solution</groupId>
<artifactId>webapi</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>webapi Maven Webapp</name>
<url>http://maven.apache.org</url> <dependencies>
<!--Module-->
<dependency>
<groupId>lm.solution</groupId>
<artifactId>service</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>lm.solution</groupId>
<artifactId>common</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency> <!--Libary-->
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
</dependency> <!--mybatis spring 插件 -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
<!-- 映入JSON lib -->
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<classifier>jdk15</classifier>
</dependency>
<!-- 用dom4j解析xml文件 -->
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
</dependency>
<!-- ehcache -->
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache-core</artifactId>
</dependency>
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache-web</artifactId>
</dependency>
<!-- 上传组件包 -->
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<!-- commons-beanutils -->
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- freemarker -->
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
</dependency> </dependencies> <build>
<finalName>webapi</finalName> <plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat8-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

  9.webservice/pom.xml

    这个模块是做为 JAX-WS  服务站点的。

    重复内容不在讲解,参考上文的说明。

 <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">
<parent>
<artifactId>solution</artifactId>
<groupId>lm.solution</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion> <groupId>lm.solution</groupId>
<artifactId>webservice</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging> <name>webservice Maven Webapp</name>
<url>http://maven.apache.org</url> <dependencies>
<!-- Module -->
<dependency>
<groupId>lm.solution</groupId>
<artifactId>service</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency> <!-- Libary -->
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-rt</artifactId>
</dependency>
</dependencies> <build>
<finalName>webservice</finalName>
</build>
</project>

                                         蒙

                                    2018-05-25 23:36 周五

基于 Maven 的多模块 Java ( Spring ) 项目构建的更多相关文章

  1. Idea基于maven搭建多模块单体结构项目

    菜鸟教程 一.创建一个公共的父工程: 1.1 创建一个新的maven项目: 1.2 先创建公共的父工程,选择maven骨架: 1.3 配置maven: 1.4 填写groupId.artifactId ...

  2. 基于maven javaweb编程缺少java源文件

    前提:基于maven的javaweb的开发环境,可参考 link 一. https://blog.csdn.net/ldlly0505/article/details/79674826 1.在sour ...

  3. Java SpringBoot 项目构建 Docker 镜像调优实践

    PS:已经在生产实践中验证,解决在生产环境下,网速带宽小,每次推拉镜像影响线上服务问题,按本文方式构建镜像,除了第一次拉取.推送.构建镜像慢,第二.三-次都是几百K大小传输,速度非常快,构建.打包.推 ...

  4. 利用 Maven 构造 Spring Cloud 微服务架构 模块使用 spring Boot构建

    采用Maven 聚合工程搭建 Spring Cloud 使用工具: IntelliJ IDEA    版本: 2019.2.2 maven             版本: 3.6.0 JDK      ...

  5. 转】[1.0.2] 详解基于maven管理-scala开发的spark项目开发环境的搭建与测试

    场景 好的,假设项目数据调研与需求分析已接近尾声,马上进入Coding阶段了,辣么在Coding之前需要干马呢?是的,“统一开发工具.开发环境的搭建与本地测试.测试环境的搭建与测试” - 本文详细记录 ...

  6. 基于MAVEN使用IDEA创建dubbo入门项目图文教程

    花了很长时间没有找到一个很详细的图文教程来学习dubbo入门框架,故记录下来. 一: 项目工程目录 简单介绍项目目录结构: 二: 创建父工程 具体操作步骤: 1,打开IDEA,按下面步骤来 File- ...

  7. java之项目构建工具Gradle

    介绍 Java 作为一门世界级主流编程语言,有一款高效易用的项目管理工具是 java 开发者共同追求的心愿和目标.显示 2000 年的 Ant,后有 2004 年的 Maven 两个工具的诞生,都在 ...

  8. Spring Boot 的Maven多模块开发web项目使用外部容器进行部署

    Spring Boot中自带有Tomcat容器,因此Spring Boot项目只需要运行main函数,就可以运行,但是以往的web项目,我们习惯于使用自己安装的Tomcat运行或者使用Tomcat.J ...

  9. 基于maven使用IDEA创建多模块项目

    原文地址:http://blog.csdn.net/williamhappy/article/details/54376855 鉴于最近学习一个分布式项目的开发,讲一下关于使用IntelliJ IDE ...

随机推荐

  1. 关闭ipv6的方法

    公司研发反应,几台机器开了一些端口,但是访问一直不通. 检查后发现,发现服务开启的是ipv6的端口,所有首先想到的办法就是关闭ipv6. 关闭ipv6的方法有两种: 第一个是在内核配置文件修改配置(p ...

  2. Day2_and_Day3 文件操作

    文件修改操作: 文件的修改操作:文件并没有修改操作,实际是将一个编写的新文件覆盖了原有的文件 替换文件中的某个内容: with open('old.txt','r',encoding='utf-8') ...

  3. Flask框架之 --- 我的第一个个人网站(雏形)

    现在还是个静态网站 , 而且这里的Flask也只是起到了提供虚拟web服务器的作用  , 下一步是实现数据库的连接 , 实现简单的动态访问.

  4. Redis+Django(Session,Cookie、Cache)的用户系统

    转自 http://www.cnblogs.com/BeginMan/p/3890761.html 一.Django authentication django authentication 提供了一 ...

  5. UE4中创建第一、第三人称角色,并进行角色间的切换

    在游戏中经常会出现第一人称和第三人称的视角切换场景,笔者在这里简单介绍如何进行这步操作. 1.创建角色 在内容浏览器中添加2个Character蓝图,分别命名为FirstPersonalCharact ...

  6. Spring Cloud Config - RSA简介以及使用RSA加密配置文件

    简介 RSA非对称加密有着非常强大的安全性,HTTPS的SSL加密就是使用这种方法进行HTTPS请求加密传输的.因为RSA算法会涉及Private Key和Public Key分别用来加密和解密,所以 ...

  7. 115个Java面试题和答案——终极列表(下)【转】

    第一篇讨论了面向对象编程和它的特点,关于Java和它的功能的常见问题,Java的集合类,垃圾收集器,本章主要讨论异常处理,Java小应用程序,Swing,JDBC,远程方法调用(RMI),Servle ...

  8. 阿里Java架构师谈谈架构和如何成为一个Java架构师

    架构的定义 我们来看看软件架构的一般定义: 程序和计算系统软件体系结构是指系统的一个或多个结构. 该结构包括软件的构建,构建的外部可见属性以及它们之间的相互关系. 该体系结构不是可操作的软件. 具体来 ...

  9. .NET开发微信小程序-上传图片到服务器

    1.上传图片分为几种: a:上传图片到本地(永久保存) b:上传图片到本地(临时保存) c:上传图片到服务器 a和b在小程序的api文档里面有.直接说C:上传图片到服务器 前端代码: /* 上传图片到 ...

  10. ubuntu18.04安装搜狗拼音

    1.下载好搜狗安装包http://pinyin.sogou.com/linux/ ,注意位数! 2.打开终端安装依赖    sudo apt install libfcitx-qt0 3.提取下载好的 ...