springclou之父工程搭建
一、创建父工程
父工程的作用是锁定接下来创建的各个module中依赖jar包的版本号一致,防止因为工程之间由于版本问题产生不可预知的后果。
我们敲定一下开发环境:
- maven 3.3.+
- jdk 1.8 +
- springcloud 2020.0.0
- springboot 2.4.1
父工程下面只放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>
<groupId>com.cxd.springcloud</groupId>
<artifactId>springcloud-demo</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
<!--############################################-->
<spring-cloud.version>2020.0.0</spring-cloud.version>
<spring-boot.version>2.4.1</spring-boot.version>
<ribbon.version>1.4.7.RELEASE</ribbon.version>
<netflix.version>3.0.0</netflix.version>
<hystrix.version>2.2.6.RELEASE</hystrix.version>
</properties>
<dependencyManagement>
<dependencies>
<!--springcloud 依赖管理-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<!--springboot 依赖管理-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<!--熔断仪表盘-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
<version>${hystrix.version}</version>
</dependency>
<!--hystrix断路器-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
<version>${hystrix.version}</version>
</dependency>
<!--#############################一下版本交由springboot springcloud dengpendencies管理###-->
<!--Web-->
<!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-starter-web</artifactId>-->
<!-- <version>${spring-boot.version}</version>-->
<!-- </dependency>-->
<!--eureka server-->
<!-- <dependency>-->
<!-- <groupId>org.springframework.cloud</groupId>-->
<!-- <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>-->
<!-- <version>3.0.0</version>-->
<!-- </dependency>-->
<!--eureka client-->
<!-- <dependency>-->
<!-- <groupId>org.springframework.cloud</groupId>-->
<!-- <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>-->
<!-- <version>3.0.0</version>-->
<!-- </dependency>-->
<!--openFeign 接口式编程,远程调用-->
<!-- <dependency>-->
<!-- <groupId>org.springframework.cloud</groupId>-->
<!-- <artifactId>spring-cloud-starter-openfeign</artifactId>-->
<!-- <version>${openfeign.version}</version>-->
<!-- </dependency>-->
<!--ribbon负载均衡-->
<!-- <dependency>-->
<!-- <groupId>org.springframework.cloud</groupId>-->
<!-- <artifactId>spring-cloud-starter-ribbon</artifactId>-->
<!-- <version>${spring-cloud.version}</version>-->
<!-- </dependency>-->
<!--springcloud gateway-->
<!-- <dependency>-->
<!-- <groupId>org.springframework.cloud</groupId>-->
<!-- <artifactId>spring-cloud-starter-gateway</artifactId>-->
<!-- </dependency>-->
<!--spring test-->
<!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-starter-test</artifactId>-->
<!-- <version>${spring-boot.version}</version>-->
<!-- </dependency>-->
<!-- actuator监控信息完善 -->
<!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-starter-actuator</artifactId>-->
<!-- <version>${spring-boot.version}</version>-->
<!-- </dependency>-->
<!-- lombok插件 -->
<!-- <dependency>-->
<!-- <groupId>org.springframework.cloud</groupId>-->
<!-- <artifactId>lombok</artifactId>-->
<!-- <version>${spring-boot.version}</version>-->
<!-- <scope>provided</scope>-->
<!-- </dependency>-->
<!--日志-->
<!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-starter-logging</artifactId>-->
<!-- <version>${spring-boot.version}</version>-->
<!-- <scope>compile</scope>-->
<!-- </dependency>-->
</dependencies>
</dependencyManagement>
<!--插件-->
<build>
<plugins>
<!-- 指定jdk -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<skip>true</skip>
<source>${java.version}</source>
<target>${java.version}</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
</plugins>
</build>
</project>
接下来搭建我们的eureka-server.