前言

最近开始学习SpringCloud 2020.0.2新的版本,筹备应用全新的架构,如图所示

所以记录下应用idea创立多模块我的项目,一步一步记录搭建的过程

创立我的项目(New Project)





增加模块(New Module)




援用SpringCloud前置操作

1、删除ztosin-parent我的项目下的src目录

2、批改ztosin-parent我的项目的的pom.xml

<?xml version="1.0" encoding="UTF-8"?><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>    <artifactId>ztosin-nacossvr</artifactId>    <parent>        <groupId>org.springframework.boot</groupId>        <artifactId>spring-boot-starter-parent</artifactId>        <version>2.4.5</version>    </parent>    <properties>        <spring.cloud-version>2020.0.2</spring.cloud-version>    </properties>    <dependencies>        <dependency>            <groupId>org.springframework.boot</groupId>            <artifactId>spring-boot-starter-web</artifactId>        </dependency>    </dependencies>    <dependencyManagement>        <dependencies>            <dependency>                <groupId>org.springframework.cloud</groupId>                <artifactId>spring-cloud-dependencies</artifactId>                <version>${spring.cloud-version}</version>                <type>pom</type>                <scope>import</scope>            </dependency>        </dependencies>    </dependencyManagement>    <build>        <plugins>            <plugin>                <groupId>com.spotify</groupId>                <artifactId>dockerfile-maven-plugin</artifactId>                <version>1.4.10</version>                <configuration>                    <dockerfile>src/main/docker/Dockerfile</dockerfile>                    <!--                    <repository>spotify/foobar</repository>-->                    <!--<tag>${project.version}</tag>-->                    <buildArgs>                        <!--提供参数向Dockerfile传递-->                        <JAR_FILE>target/${project.build.finalName}.jar</JAR_FILE>                    </buildArgs>                </configuration>            </plugin>            <plugin>                <groupId>org.springframework.boot</groupId>                <artifactId>spring-boot-maven-plugin</artifactId>            </plugin>        </plugins>    </build></project>

3、增加NacosServerApplication.java

package com.ztosin.nacossvr;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;@SpringBootApplicationpublic class NacosServerApplication {    public static void main(String[] args) {        SpringApplication.run(NacosServerApplication.class, args);    }}

最终目录构造如下所示 :

参考

spring-cloud
应用 IDEA 创立多模块我的项目