1.1.1 单体架构的优点
项目的官方网址: https://projects.spring.io/spring-cloud/
并且也可以看到最新Edgware.SR4稳定版对应的子项目的各个版本号。
在src/main/resources目录下创建一个application.properties配置文件在该文件中可以配置如下内容
server.port=8081
3.2.3 创建实体OrderDetail
![Spring-Cloud微服务13.1](https://blog.ytso.com/wp-content/themes/justnews/themer/assets/images/lazy.png)
![Spring-Cloud微服务13.2](https://blog.ytso.com/wp-content/themes/justnews/themer/assets/images/lazy.png)
![Spring-Cloud微服务13.3](https://blog.ytso.com/wp-content/themes/justnews/themer/assets/images/lazy.png)
![Spring-Cloud微服务13.4](https://blog.ytso.com/wp-content/themes/justnews/themer/assets/images/lazy.png)
修改ItemService的实现通过@Value 注解获取该值
public static void main(String[] args) {
4.3.4 启动商品微服务
![Spring-Cloud微服务4.3.4](https://blog.ytso.com/wp-content/themes/justnews/themer/assets/images/lazy.png)
至此我们就已经将商品微服务注册到Eureka注册中心了
4.4 订单系统从Eureka中发现服务
4.4.1 修改pom.xml
![Spring-Cloud微服务4.4.1](https://blog.ytso.com/wp-content/themes/justnews/themer/assets/images/lazy.png)
之前我们在订单系统中是将商品微服务的地址进行了硬编码,现在,由于已经将商品服务注册到Eureka中,所以,只需要从Eureka中发现服务即可。引入Spring Cloud 的管理依赖以及Eureka服务依赖。
![Spring-Cloud微服务4.4.2](https://blog.ytso.com/wp-content/themes/justnews/themer/assets/images/lazy.png)
![Spring-Cloud微服务4.4.3](https://blog.ytso.com/wp-content/themes/justnews/themer/assets/images/lazy.png)
![Spring-Cloud微服务4.4.5.1](https://blog.ytso.com/wp-content/themes/justnews/themer/assets/images/lazy.png)
![Spring-Cloud微服务4.4.5.2](https://blog.ytso.com/wp-content/themes/justnews/themer/assets/images/lazy.png)
测试
![Spring-Cloud微服务4.4.6.2](https://blog.ytso.com/wp-content/themes/justnews/themer/assets/images/lazy.png)
4.5.3 Eureka的自我保护模式
![Spring-Cloud微服务4.5.3.1](https://blog.ytso.com/wp-content/themes/justnews/themer/assets/images/lazy.png)
![Spring-Cloud微服务4.5.4.3](https://blog.ytso.com/wp-content/themes/justnews/themer/assets/images/lazy.png)
![Spring-Cloud微服务4.5.4.1](https://blog.ytso.com/wp-content/themes/justnews/themer/assets/images/lazy.png)
![Spring-Cloud微服务4.5.4.2](https://blog.ytso.com/wp-content/themes/justnews/themer/assets/images/lazy.png)
![Spring-Cloud微服务4.5.4.3](https://blog.ytso.com/wp-content/themes/justnews/themer/assets/images/lazy.png)
eureka.client.serviceUrl.defaultZone= http://itcast:itcast123@127.0.0.1:6868/eureka/,http://itcast:itcast123@127.0.0.1:6869/eureka/
![Spring-Cloud微服务4.5.5.1](https://blog.ytso.com/wp-content/themes/justnews/themer/assets/images/lazy.png)
![Spring-Cloud微服务4.5.5.2](https://blog.ytso.com/wp-content/themes/justnews/themer/assets/images/lazy.png)
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/253588.html