1. 程式人生 > >SpringCloud第六篇 maven module管理多節點專案

SpringCloud第六篇 maven module管理多節點專案

1.效果圖

2.新建maven專案

選擇pom

2.如果有src檔案目錄,刪掉即可

3.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>com.star.guo</groupId> -->
    <artifactId>stage1</artifactId>
    <!-- <version>0.0.1-SNAPSHOT</version> -->
    <packaging>pom</packaging>
    <parent>
        <groupId>com.star.guo</groupId>
        <artifactId>springcloudversion</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>
    <modules>
        <module>eureka</module>
        <module>eureka-client</module>
        <module>eureka-client2</module>
        <module>ribbon-client</module>
        <module>feign-client</module>
    </modules>
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>

4.修改之前專案的pom.mxl裡面的parent

<!--         <artifactId>springcloudversion</artifactId> -->
        <artifactId>stage1</artifactId>

5.移動專案到stage1下面

6.軟刪除所有專案並重新匯入

7.如果錯誤則注意pom..xml包括module專案裡面的配置,如命名是否正確,然後選擇Eclipse Project Explorer ,

如果比較多則應該新建的時候就這樣,否則建立好之後重新匯入比較方便

在stage1右鍵選擇 maven->New Maven Module Project

這種情況我的使用風格是針對節點多的時候,管理分類比較方便。

stage2的pom.xml記得新增module,hystrix的pom.xml記得修改parent

    <modules>
        <module>hystrix</module>
    </modules>

    <parent>
        <groupId>com.star.guo</groupId>
        <artifactId>stage2</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <relativePath /> <!-- lookup parent from repository -->此行在hystrix中刪掉
    </parent>