• 开源项目 cloud-platform 的本地部署


    F7 单步调试,进入函数内部

    F8 单步调试,不进入函数内部

    F9 继续执行,进入下一个断点或执行完程序

    Shift+F7 选择要进入的函数

    Shift+F8 跳出函数

    Ctrl+F8 设置/取消当前行断点

    Ctrl+Shift+F8 查看断点

    Alt+F8 执行表达式查看结果

    Alt+F9 运行到断点

    一,mysql 的数据库安装:https://www.cnblogs.com/xcj26/p/12573385.html

    二,nacos 的配置与启动:https://www.cnblogs.com/xcj26/p/12575640.html

    三,修改项目的数据库连接:

    在使用JDBC连接mysql时,出现如下异常:

    The server time zone value '?й???׼ʱ?' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.

    连接字符串要加上:serverTimezone=UTC  参数

    参数名称                    参数说明                                                                                缺省值     最低版本要求
    user                      数据库用户名(用于连接数据库)                                                                         所有版本
    password                   用户密码(用于连接数据库)                                                                           所有版本
    useUnicode              是否使用Unicode字符集,如果参数characterEncoding设置为gb2312或gbk,本参数值必须设置为true        false     1.1g
    characterEncoding       当useUnicode设置为true时,指定字符编码。比如可设置为gb2312或gbk                                false     1.1g
    autoReconnect                当数据库连接异常中断时,是否自动重新连接?                                                false     1.1
    autoReconnectForPools     是否使用针对数据库连接池的重连策略                                                          false     3.1.3
    failOverReadOnly         自动重连成功后,连接是否设置为只读?                                                         true     3.0.12
    maxReconnects           autoReconnect设置为true时,重试连接的次数                                                   3     1.1
    initialTimeout        autoReconnect设置为true时,两次重连之间的时间间隔,单位:秒                                      2     1.1
    connectTimeout       和数据库服务器建立socket连接时的超时,单位:毫秒。 0表示永不超时,适用于JDK 1.4及更高版本              0     3.0.1
    socketTimeout          socket操作(读写)超时,单位:毫秒。 0表示永不超时                                              0     3.0.1

    修改两个项目的数据连接:

    cloud-platformace-authace-auth-serversrcmain esources    ->  application.yml

    cloud-platformace-modulesace-adminsrcmain esources    ->  application.yml

    留意修改数据库名:

    datasource:
        name: test
        url: jdbc:mysql://${MYSQL_HOST:192.168.11.89}:${MYSQL_PORT:3306}/ag_admin_v1?useUnicode=true&characterEncoding=UTF8&serverTimezone=UTC
        username: root
        password: Abc123
        # 使用druid数据源
        type: com.alibaba.druid.pool.DruidDataSource
        driver-class-name: com.mysql.jdbc.Driver
        filters: stat
        maxActive: 20
        initialSize: 1
        maxWait: 60000
        minIdle: 1
        timeBetweenEvictionRunsMillis: 60000
        minEvictableIdleTimeMillis: 300000
        validationQuery: select 'x'
        testWhileIdle: true
        testOnBorrow: false
        testOnReturn: false
        poolPreparedStatements: true
        maxOpenPreparedStatements: 20

    在项目服务启动的时候就去加载一些数据或做一些事情这样的需求,为了解决这样的问题,在Spring Boot 中,实现接口 CommandLineRunner 即可。

     cloud-platformace-authace-auth-clientsrcmainjavacomgithubwxiaoqisecurityauthclient unner     ->  AuthClientRunner.java  文件。

    Spring Cloud Gateway

    feign 和 ribbon 是 Spring Cloud 的 Netflix 中提供的两个实现软负载均衡的组件,Ribbon 和 Feign 都是用于调用其他服务的,方式不同。Feign 则是在 Ribbon 的基础上进行了一次改进,采用接口的方式,将需要调用的其他服务的方法定义成抽象方法即可,不需要自己构建 http 请求。不过要注意的是抽象方法的注解、方法签名要和提供服务的方法完全一致。

    一:mysql连接的修改

    在Idea环境下, Ctrl + Shift  + F  全文搜索:   jdbc:mysql://    关键字,修改数据库的连接。

    其实就是改绿色框圈起来的两个地方

     修改内容如下,记得切换数据库IP,端口,数据库名,用户名,密码:

    datasource:
        name: test
        url: jdbc:mysql://${MYSQL_HOST:192.168.9.87}:${MYSQL_PORT:3306}/ag_auth_v1?useUnicode=true&characterEncoding=UTF8
        username: root
        password: pwd******
        # 使用druid数据源
        type: com.alibaba.druid.pool.DruidDataSource
        driver-class-name: com.mysql.jdbc.Driver
        filters: stat
        maxActive: 20
        initialSize: 1
        maxWait: 60000
        minIdle: 1
        timeBetweenEvictionRunsMillis: 60000
        minEvictableIdleTimeMillis: 300000
        validationQuery: select 'x'
        testWhileIdle: true
        testOnBorrow: false
        testOnReturn: false
        poolPreparedStatements: true
        maxOpenPreparedStatements: 20

    搜索   rabbitmq:   关键字:

     修改rabbitmq的IP,端口,用户名,密码

      rabbitmq:
          host: ${RABBIT_MQ_HOST:localhost}
          port:  ${RABBIT_MQ_PORT:5672}
          username: guest
          password: guest

    搜索  redis: 

     修改redis的相关配置:

      redis:
        database: 2
        host: ${REDIS_HOST:192.168.9.87}
        port: ${REDIS_PORT:6379}
        pool:
        max-active: 20
        password: 123456

    在spring boot中引用 redis时,需要添加

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-redis</artifactId>
    </dependency>

      redis:
        database: 2
        host: ${REDIS_HOST:127.0.0.1}
        port: ${REDIS_PORT:6379}
        pool:
        max-active: 20
        password: ******
    spring:
      redis:
        database: 6   # Redis数据库索引(默认为0)
        host: redis.lilian.com  # Redis服务器地址
        port: 7481  # Redis服务器连接端口
        password:    # Redis服务器连接密码(默认为空)
        timeout: 0  # 连接超时时间(毫秒)
        pool:
          max-active: -1 # 连接池最大连接数(使用负值表示没有限制)
          max-wait: -1  # 连接池最大阻塞等待时间(使用负值表示没有限制)
          max-idle: 8  # 连接池中的最大空闲连接
          min-idle: 0  # 连接池中的最小空闲连接
      redis2:
        database: 6   # Redis数据库索引(默认为0)
        host: redis.lilian.com  # Redis服务器地址
        port: 7480  # Redis服务器连接端口
        password:    # Redis服务器连接密码(默认为空)
        timeout: 0  # 连接超时时间(毫秒)

    提示内容:

    Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.

    解决方法:将加载数据库驱动的语句更改 com.mysql.cj.jdbc.Driver

    5.x版本的驱动文件jar包对应的是:
    Class.forName("com.mysql.jdbc.Driver");
    语句来加载数据库驱动

    8.0x版本的驱动文件jar包对应的是:
    Class.forName("com.mysql.cj.jdbc.Driver");

  • 相关阅读:
    两个有序链表的合并
    阶乘求和优化思考
    ### Error building SqlSession. ### The error may exist in SQL Mapper Configuration ### Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: org.apache.ibat
    ### Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: org.apache.ibatis.builder.BuilderException: Error creating document instance. Cause: org.xml.sax.
    Error querying database. Cause: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'ItemsCustom' in 'class com.pojo.OrderDetailCustom
    org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: java.lang.NumberFormatException: For input string: "W%" ### Cause: java.lang.NumberFormatException: For input s
    java发送http的get、post请求
    Echarts 中当y轴有负数时,让x轴下落在y轴最小值
    Echarts数据可视化grid直角坐标系(xAxis、yAxis)详解:
    Echarts datazoom数据区域缩放
  • 原文地址:https://www.cnblogs.com/xcj26/p/12627341.html
Copyright © 2020-2023  润新知