1. 建立 Java Working Set:工程多的时候可以展开收缩,方便管理
    springcloud工程建立 父工程+公用子模块+微服务提供模块

    切换到Package Explorer视图,并点击视图右侧下箭头,选择Working Sets,如下图:
    springcloud工程建立 父工程+公用子模块+微服务提供模块

  2. 建立父工程,将后续子工程公共的Jar包提出来:
    • 选择Working Set,右键New -> Maven Project:
      springcloud工程建立 父工程+公用子模块+微服务提供模块
    • 选择 Create a simple project,点击下一步
      springcloud工程建立 父工程+公用子模块+微服务提供模块

    • 创建父工程,父工程名称:thrcloud,Packaging:选择pom
      springcloud工程建立 父工程+公用子模块+微服务提供模块

    • 父工程建立完成,修改pom.xml文件:
      springcloud工程建立 父工程+公用子模块+微服务提供模块

      pom.xml文件内容如下,springcloud和springboot的版本可以选择比较新的版本对应关系,我这里比较旧:

      <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>com.thr.springcloud</groupId>
          <artifactId>thrcloud</artifactId>
          <version>0.0.1-SNAPSHOT</version>
          <packaging>pom</packaging>
      
          <properties>
              <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
              <maven.compiler.source>1.8</maven.compiler.source>
              <maven.compiler.target>1.8</maven.compiler.target>
              <junit.version>4.12</junit.version>
              <log4j.version>1.2.17</log4j.version>
              <lombok.version>1.18.4</lombok.version>
          </properties>
      
          <dependencyManagement>
              <dependencies>
                  <dependency>
                      <groupId>org.springframework.cloud</groupId>
                      <artifactId>spring-cloud-dependencies</artifactId>
                      <version>Dalston.SR1</version>
                      <type>pom</type>
                      <scope>import</scope>
                  </dependency>
                  <dependency>
                      <groupId>org.springframework.boot</groupId>
                      <artifactId>spring-boot-dependencies</artifactId>
                      <version>1.5.9.RELEASE</version>
                      <type>pom</type>
                      <scope>import</scope>
                  </dependency>
                  <dependency>
                      <groupId>mysql</groupId>
                      <artifactId>mysql-connector-java</artifactId>
                      <version>8.0.14</version>
                  </dependency>
                  <dependency>
                      <groupId>com.alibaba</groupId>
                      <artifactId>druid</artifactId>
                      <version>1.0.31</version>
                  </dependency>
                  <dependency>
                      <groupId>org.mybatis.spring.boot</groupId>
                      <artifactId>mybatis-spring-boot-starter</artifactId>
                      <version>1.3.0</version>
                  </dependency>
                  <dependency>
                      <groupId>ch.qos.logback</groupId>
                      <artifactId>logback-core</artifactId>
                      <version>1.2.3</version>
                  </dependency>
                  <dependency>
                      <groupId>junit</groupId>
                      <artifactId>junit</artifactId>
                      <version>${junit.version}</version>
                      <scope>test</scope>
                  </dependency>
                  <dependency>
                      <groupId>log4j</groupId>
                      <artifactId>log4j</artifactId>
                      <version>${log4j.version}</version>
                  </dependency>
              </dependencies>
          </dependencyManagement>
      
      </project>
      View Code

相关文章: