创建一个微服务项目

微服务的设计原则:

1、单一职责原则 一个微服务只干一件事
2、服务自治原则 每个微服务应该能做到独立开发、测试、部署、维护,不需要其他模块的参与
3、轻量级通讯原则 最好能够通过http请求在服务之间进行互相的调用
4、接口明确原则 微服务之间进行访问、调用都是通过接口的方式进行调用,尽量避免在一个微服务
中包含其他微服务的内容

微服务版本对应关系

在这里插入图片描述

使用spring cloud做微服务的大体结构

在这里插入图片描述

开发步骤:

创建项目为maven项目,我的jdk版本是jdk1.8,因此需要改动一下maven配置文件,将jdk版本改为jdk1.8,不然建立的项目为jdk1.5版本如图
在这里插入图片描述

修改:maven下的setting.xml文件

在这里插入图片描述
在200行左右找到如下位置,改为:在这里插入图片描述
复制代码块粘贴进去

<profile>

<id>jdk-1.8</id>

<activation>

<activeByDefault>true</activeByDefault>

<jdk>1.8</jdk>

</activation>

<properties>

<maven.compiler.source>1.8</maven.compiler.source>

<maven.compiler.target>1.8</maven.compiler.target>

<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>

</properties>

</profile>

创建项目:

①创建父工程

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

②:在父工程导入依赖

<dependencyManagement>
  	<dependencies>
  		<!-- spring cloud -->
  		<dependency>
		    <groupId>org.springframework.cloud</groupId>
		    <artifactId>spring-cloud-dependencies</artifactId>
		    <version>Greenwich.SR1</version>
		    <type>pom</type>
		    <scope>runtime</scope>
		</dependency>

  		<!-- spring boot -->
  		<dependency>
  			<groupId>org.springframework.boot</groupId>
  			<artifactId>spring-boot-dependencies</artifactId>
  			<version>2.1.0.RELEASE</version>
  			<type>pom</type>
  			<scope>import</scope>
  		</dependency>
  		
  		<!-- mysql -->
  		<dependency>
		    <groupId>mysql</groupId>
		    <artifactId>mysql-connector-java</artifactId>
		    <version>5.1.44</version>
		</dependency>
		
		<!-- druid -->
		<dependency>
		    <groupId>com.alibaba</groupId>
		    <artifactId>druid</artifactId>
		    <version>1.1.15</version>
		</dependency>
  		
  		<!-- mybatis -->
  		<dependency>
		    <groupId>org.mybatis.spring.boot</groupId>
		    <artifactId>mybatis-spring-boot-starter</artifactId>
		    <version>1.3.2</version>
		</dependency>
		
		<!-- junit -->
		<dependency>
		    <groupId>junit</groupId>
		    <artifactId>junit</artifactId>
		    <version
  • 0
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值