关于springcloud:IDEA-创建基于SpringCloud多模块项目

27次阅读

共计 2032 个字符,预计需要花费 6 分钟才能阅读完成。

前言

最近开始学习 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;

@SpringBootApplication
public class NacosServerApplication {public static void main(String[] args) {SpringApplication.run(NacosServerApplication.class, args);
    }
}

最终目录构造如下所示:

参考

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

正文完
 0