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-platform\ace-auth\ace-auth-server\src\main\resources -> application.yml
cloud-platform\ace-modules\ace-admin\src\main\resources -> 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-platform\ace-auth\ace-auth-client\src\main\java\com\github\wxiaoqi\security\auth\client\runner -> 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");