springCloud 尚硅谷 周阳教程学习 -- 第一部分基础

简介

名称: 尚硅谷2020最新版SpringCloud(H版&alibaba)
时长: 26 H
集数: 150
作者: 周阳
21章 14种组件技术 10天的学习周期

-------基础P1~P14 (20201018—20201021)
-------初级P15~P46 (20201022—20201024 )
-------中级P
-------高级P

周阳套路

  1. 是什么
  2. 能干嘛
  3. 去哪下
  4. 怎么玩

基础
在这里插入图片描述

初级
在这里插入图片描述中级
在这里插入图片描述在这里插入图片描述
高级
在这里插入图片描述

笔记: Typora \ 印象笔记
思维导图: XMind \ MindMaster

微服务基础架构

在这里插入图片描述

SpringCloud组件及其替换组件

在这里插入图片描述

P05 – springCloud 父工程控件的创建

在这里插入图片描述https://www.bilibili.com/video/BV18E411x7eT?p=5

8001 8002 服务提供者可以运行的条件是

  1. 本地Mysql开启,且密码没有问题(我公司与家里密码不一致)
  2. 本地Hosts文件修改,兼容集群访问(服务名就是本地主机127.0.0.1)
    C:\Windows\System32\drivers\etc
    在这里插入图片描述

P06父工程pom文件

https://www.bilibili.com/video/BV18E411x7eT?p=6


<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.atguigu.springcloud</groupId>
  <artifactId>cloud2020</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>pom</packaging>


  <!--统一管理jar包版本-->
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compile.source>1.8</maven.compile.source>
    <maven.compile.target>1.8</maven.compile.target>
    <junit.version>4.12</junit.version>
    <log4j.version>1.2.17</log4j.version>
    <lombok.version>1.16.18</lombok.version>
    <mysql.version>5.1.47</mysql.version>
    <druid.version>1.1.16</druid.version>
    <mybatis.spring.boot.version>1.3.0</mybatis.spring.boot.version>
  </properties>

  <!-- 子模块继承之后,提供作用:锁定版本+子module 不用写 groupId 和 version  -->
  <dependencyManagement>
    <dependencies>
      <!--spring boot 2.2.2-->
      <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-dependencies</artifactId>
        <version>2.2.2.RELEASE</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
      <!-- SpringCloud Hoxton.SR1 -->
      <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-dependencies</artifactId>
        <version>Hoxton.SR1</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
      <!--spring cloud alibaba 2.1.0.RELEASE-->
      <dependency>
        <groupId>com.alibaba.cloud</groupId>
        <artifactId>spring-cloud-alibaba-dependencies</artifactId>
        <version>2.1.0.RELEASE</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>


      <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>${mysql.version}</version>
      </dependency>
      <dependency>
        <groupId>com.alibaba</groupId>
        <artifactId>druid</artifactId>
        <version>${druid.version}</version>
      </dependency>
      <dependency>
        <groupId>org.mybatis.spring.boot</groupId>
        <artifactId>mybatis-spring-boot-starter</artifactId>
        <version>${mybatis.spring.boot.version}</version>
      </dependency>
      <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>${junit.version}</version>
      </dependency>
      <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <version>${lombok.version}</version>
        <optional>true</optional>
      </dependency>

    </dependencies>
  </dependencyManagement>

  <build>
    <plugins>
      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <configuration>
          <fork>true</fork>
          <addResources>true</addResources>
        </configuration>
      </plugin>
    </plugins>
  </build>


</project>

P7 DependencyManagement vs Dependency

https://www.bilibili.com/video/BV18E411x7eT?p=7
Maven父类中的DependencyManagement 引入的依赖,并不实际调用下载
只有在子类的Dependencids中实际引入后,才执行实际的调用

P08 P09 P10 支付模块构建

https://www.bilibili.com/video/BV18E411x7eT?p=8

编码创建过程

  1. 建module
  2. 改pom
  3. 写YML
  4. 主启动
  5. 业务类
    5.1 建表SQL
    5.2 entities
    -------------5.2.1 主实体 Payment
    -------------5.2.2 json封装实体 CommonResult
    5.3 dao
    5.4 service
    -------------5.4.1 service 接口
    -------------5.4.2 service 接口实现类
    5.5 controller

postman 测试 — 3 m
https://www.bilibili.com/video/BV18E411x7eT?p=10

8、测试
1、get测试:浏览器输入:http://localhost:8001/payment/get/2

结果:{“code”:200,“message”:“查询数据成功”,“data”:{“id”:2,“serial”:“alibaba”}}

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

run vs run dashboard

开启 Run DashBoard
默认开启两个module是打开 dashBoard 的

在这里插入图片描述

RunDashboard 节点下面增加 configurationType 节点如下

<component name="RunDashboard">
    <option name="configurationTypes">
      <set>
        <option value="SpringBootApplicationConfigurationType" />
      </set>
    </option>

在这里插入图片描述

Devtools —热部署插件

https://www.bilibili.com/video/BV18E411x7eT?p=11

  1. add devtools to project (子工程)
  2. add plugin to pom (父工程)
  3. enabling automatic build
  4. Update the value of
  5. 重启IDEA

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

在这里插入图片描述
compiler.automake.allow.when.app.running
actionSystem.assertFocusAccessFromEdt

12 13 消费者订单模块

微服务提供者 端口号 8001
客户端消费者 端口号 80

在这里插入图片描述

httpClient 升级到 restTemplate
spring是容器处理集合
引入restTemplate需要使用config配置引入RestTemplate 的bean

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值