首页天道酬勤springcloud官网,springcloud五大组件

springcloud官网,springcloud五大组件

张世龙 05-05 12:53 47次浏览

1、引入依赖于GitEgg项目根目录、顶层父pom.xml文件的库和Maven插件,设置编码方式:

? XML版本=' 1.0 '编码=' utf-8 '? project xmlns=' http://maven.Apache.org/POM/4.0.0 ' xmlns : xsi=' http://www.w3.org/2001/XML方案ins ttins maven-4.0.0.xsd ' model版本4.0.0/modelversiongroupidcom.gide artifactidnamegitegg-cloud/namepackagingpopod versionmodulesmodulegitegg-common/moduler modulemodulegitegg-gateway/modulemodulegitegg-plugin/modulemodulegitegitegg-modulegitegg -- maven-compiler-plugin插件版本,编译Java代码--maven.plugin.version3.8.1/maven.plugin.version! -- maven编译时指定编码utf-8---- maven.com piler.encoding utf-8/maven.com piler.encoding! -项目集成字符集代码utf-8---- project.build.sourceencodingutf-8/project.build.source encoding! -项目集成字符集代码utf-8---- project.reporting.outputencodingutf-8/project.reporting.output encoding! -- GitEgg项目统一设置版本号--git egg.project.version 1.0-snapshot/git egg.project.version! -- SpringBoot版本号----spring.boot.version2.3.3. release/spring.boot.version! -- SpringCloud版本号----spring.cloud.version hoxton.sr8/spring.cloud.version/properties dependencies! -- Lombok用简单的注释去除冗馀代码--dependencygroupidorg.project lombok/groupidartifactidlombok/artifact id/dependency /

ot-starter-parent --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-dependencies</artifactId> <version>${spring.boot.version}</version> <type>pom</type> <scope>import</scope> </dependency> <!-- spring cloud工程的依赖库 --> <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> <finalName>${project.name}</finalName> <resources> <resource> <directory>src/main/resources</directory> </resource> <resource> <directory>src/main/java</directory> <includes> <include>**/*.xml</include> </includes> </resource> </resources> <pluginManagement> <plugins> <!-- 能够将Spring Boot应用打包为可执行的jar或war文件,然后以通常的方式运行Spring Boot应用 --> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <version>${spring.boot.version}</version> <configuration> <fork>true</fork> <finalName>${project.build.finalName}</finalName> </configuration> <executions> <execution> <goals> <goal>repackage</goal> </goals> </execution> </executions> </plugin> </plugins> </pluginManagement> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>${maven.plugin.version}</version> <configuration> <source>${java.version}</source> <target>${java.version}</target> <encoding>UTF-8</encoding> <compilerArgs> <arg>-parameters</arg> </compilerArgs> </configuration> </plugin> </plugins> </build></project>

2、修改gitegg-service的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"> <parent> <artifactId>GitEgg-Cloud</artifactId> <groupId>com.gitegg.cloud</groupId> <version>1.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>gitegg-service</artifactId> <packaging>pom</packaging> <modules> <module>gitegg-service-base</module> <module>gitegg-service-bigdata</module> <module>gitegg-service-system</module> </modules> <dependencies> <!-- spring boot web核心包 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <!-- spring boot 健康监控 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency> </dependencies> </project>

3、在gitegg-service-system工程下新建GitEggSystemApplication主启动类:

package com.gitegg.service.system;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;/** * gitegg-system 启动类 */@SpringBootApplicationpublic class GitEggSystemApplication { public static void main(String[] args) { SpringApplication.run(GitEggSystemApplication.class,args); }}

4、在gitegg-service-system工程的resources目录下新建application.yml文件:

server: port: 8001spring: application: name: gitegg-service-system

5、在GitEggSystemApplication类上右键,Run ‘GitEggSystemApplicat…’ ,运行项目,可以看到最基础的SpringBoot项目启动成功:

本文源码在https://gitee.com/wmz1930/GitEgg 的chapter-04分支。

GitEgg-Cloud是一款基于SpringCloud整合搭建的企业级微服务应用开发框架,开源项目地址:

Gitee: https://gitee.com/wmz1930/GitEgg
GitHub: https://github.com/wmz1930/GitEgg

欢迎感兴趣的小伙伴Star支持一下。

springcloud官网,阿里巴巴开发手册2021