构建SpringCloud_Rest微服务,父工程构建步骤

2025-05-08 01:22:50

1、我们构建SpringCloud微服务架构使用的SpringCloud版本是Dalston.SR1。SpringBoot的版本是1.5.9.RELEASE。

构建SpringCloud_Rest微服务,父工程构建步骤

2、新建父工程microservicecloud,切记是packaging是pom模式。

构建SpringCloud_Rest微服务,父工程构建步骤

3、在pom文件中将后续各个子模块公用的jar包等统一提出来。<?xml ver衡痕贤伎sion="1.0" encodi荏鱿胫协ng="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.gwolf.springcloud</groupId> <artifactId>microservicecloud</artifactId> <version>1.0-SNAPSHOT</version> <packaging>pom</packaging> <name>microservicecloud</name> <url>http://www.example.com</url> <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> </properties> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.11</version> <scope>test</scope> </dependency> </dependencies> <build> <pluginManagement> <plugins> <plugin> <artifactId>maven-clean-plugin</artifactId> <version>3.0.0</version> </plugin> <plugin> <artifactId>maven-resources-plugin</artifactId> <version>3.0.2</version> </plugin> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>3.7.0</version> </plugin> <plugin> <artifactId>maven-surefire-plugin</artifactId> <version>2.20.1</version> </plugin> <plugin> <artifactId>maven-jar-plugin</artifactId> <version>3.0.2</version> </plugin> <plugin> <artifactId>maven-install-plugin</artifactId> <version>2.5.2</version> </plugin> <plugin> <artifactId>maven-deploy-plugin</artifactId> <version>2.8.2</version> </plugin> </plugins> </pluginManagement> </build></project>

构建SpringCloud_Rest微服务,父工程构建步骤

4、在pom文件中增加springcloud依赖配置文件:<dependency怡觎现喾Management> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>Dalston.SR1</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement>

构建SpringCloud_Rest微服务,父工程构建步骤

5、在pom文件中增加springboot依赖配置文件:<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-dependencies</artifactId> <version>1.5.9.RELEASE</version> <type>pom</type> <scope>import</scope> </dependency>

构建SpringCloud_Rest微服务,父工程构建步骤

6、配置springcloud编译打包插件:<plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin>

构建SpringCloud_Rest微服务,父工程构建步骤

7、这样就完成了springcloud父工程的搭建。

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢