maven构建模块化工程要注意的问题

今天学习分布式架构,第一步就是用maven构建模块化功能;记录以下要注意的问题

1.父模块要声明子模块的位置(通过module标签)============module的位置这里指的是相对路径

  <groupId>taotao</groupId>
  <artifactId>taotao-parent</artifactId>
  <version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
  <name>taotao-parent</name>
  <!-- FIXME change it to the project's website -->
  <url>http://www.example.com</url>
<modules>
  <module>../taotao-common</module>
  <module>../taotao-manager</module>
</modules>

2.子模块要生明继承的父模块<parent> 并且要声明父模块的pom.xml文件的位置

<parent>
  <groupId>taotao</groupId>
  <artifactId>taotao-parent</artifactId>
  <version>1.0-SNAPSHOT</version>
  <relativePath>../taotao-parent/pom.xml</relativePath>
</parent>

3.模块与模块之间在相互引用时(或者一个模块依赖另一个模块时),必须要指定所依赖模块的版本号,否则依赖会失败(dependency=========version=1.0-snapshot)

 <!-- 依赖管理 -->
  <dependencies>
    <dependency>
      <groupId>taotao</groupId>
      <artifactId>taotao-common</artifactId>
      <version>1.0-SNAPSHOT</version>
    </dependency>
  </dependencies>
  <modules>
    <module>taotao-manager-pojo</module>
    <module>taotao-manager-service</module>
    <module>taotao-manager-dao</module>
    <module>taotao-manager-interface</module>
    <module>taotao-manager-web</module>
    <module>taotao-manager-mapper</module>
  </modules>

猜你喜欢

转载自blog.csdn.net/qq_41063141/article/details/88775538