spring cloud2.0构建分布式企业微服务云架构-搭建commonservice跟项目
我们先从搭建通用服务开始,首先沟通maven创建commonservice的根项目,里面有一些基础的配置信息,如:版本控制、打包、编译、依赖、通用包配置、模块等,我直接将代码帖进来,希望大家能够理解的更到位:Xml代码
<span style="font-size: 16px;"><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.honghu.cloud</groupId><artifactId>commonservice</artifactId><version>2.0</version><packaging>pom</packaging><modules><module>commonservice-eureka</module><module>commonservice-config</module><module>commonservice-gateway</module><module>commonservice-oauth</module><module>commonservice-monitor</module><module>commonservice-turbine</module><module>commonservice-admin</module><module>commonservice-log</module><module>commonservice-file</module><module>commonservice-notification</module><module>commonservice-sequence</module></modules><parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>2.0.4.RELEASE</version></parent><properties><spring-cloud.version>Finchley.RELEASE</spring-cloud.version><mybatis.version>1.3.2</mybatis.version><jwt.version>0.9.0</jwt.version><fastjson.version>1.2.47</fastjson.version><commons-collections>4.1</commons-collections><monitor.version>2.0.2</monitor.version><swagger.version>2.8.0</swagger.version><aliyun-sdk-oss.version>2.8.2</aliyun-sdk-oss.version><aliyun-sdk-core.version>3.2.8</aliyun-sdk-core.version><aliyun-sdk-dysmsapi.version>1.1.0</aliyun-sdk-dysmsapi.version><elasticsearch.version>6.2.3</elasticsearch.version><security-oauth2.version>2.3.3.RELEASE</security-oauth2.version><docker.image.prefix>springboot</docker.image.prefix></properties><dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-actuator</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId></dependency><dependency><groupId>com.alibaba</groupId><artifactId>fastjson</artifactId><version>${fastjson.version}</version></dependency><dependency><groupId>org.apache.commons</groupId><artifactId>commons-lang3</artifactId></dependency><dependency><groupId>org.apache.commons</groupId><artifactId>commons-collections4</artifactId><version>${commons-collections}</version></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><dependency><groupId>org.mybatis.spring.boot</groupId><artifactId>mybatis-spring-boot-starter</artifactId><version>${mybatis.version}</version></dependency><dependency><groupId>io.jsonwebtoken</groupId><artifactId>jjwt</artifactId><version>${jwt.version}</version></dependency></dependencies></dependencyManagement></project></span>基础配置:groupId、artifactId、version(2.0版本)Xml代码
<span style="font-size: 16px;"><groupId>com.honghu.cloud</groupId><artifactId>commonservice</artifactId><version>2.0</version><packaging>pom</packaging></span>子项目模块:Xml代码
<span style="font-size: 16px;"><modules><module>commonservice-eureka</module><module>commonservice-config</module><module>commonservice-gateway</module><module>commonservice-oauth</module><module>commonservice-monitor</module><module>commonservice-turbine</module><module>commonservice-user</module><module>commonservice-admin</module><module>commonservice-log</module><module>commonservice-file</module><module>commonservice-notification</module><module>commonservice-sequence</module></modules></span>commonservice-eureka(服务注册中心)commonservice-config(服务配置中心)commonservice-gateway(服务网关)commonservice-monitor(服务监控)commonservice-turbine(集群监控)commonservice-notification(系统通知)commonservice-oauth(服务权限)commonservice-sequence(自动生成分布式ID)commonservice-file(文件服务)commonservice-log(日志服务)commonservice-admin(通用管理集成平台)Spring Boot2.0版本(企业架构源码可以加求球:三五三六二四七二五九)Xml代码
<span style="font-size: 16px;"><parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>2.0.4.RELEASE</version></parent></span>通用版本号配置Xml代码
<span style="font-size: 16px;"><properties><spring-cloud.version>Finchley.RELEASE</spring-cloud.version><mybatis.version>1.3.2</mybatis.version><jwt.version>0.9.0</jwt.version><fastjson.version>1.2.47</fastjson.version><commons-collections>4.1</commons-collections><monitor.version>2.0.2</monitor.version><swagger.version>2.8.0</swagger.version><aliyun-sdk-oss.version>2.8.2</aliyun-sdk-oss.version><aliyun-sdk-core.version>3.2.8</aliyun-sdk-core.version><aliyun-sdk-dysmsapi.version>1.1.0</aliyun-sdk-dysmsapi.version><elasticsearch.version>6.2.3</elasticsearch.version><security-oauth2.version>2.3.3.RELEASE</security-oauth2.version><docker.image.prefix>springboot</docker.image.prefix></properties></span>