栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

SpringCloud集成Nacos的使用小结

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

SpringCloud集成Nacos的使用小结

Nacos 注册中心

Nacos 是 Dubbo 生态系统中重要的注册中心实现,其中 dubbo-registry-nacos 则是 Dubbo 融合 Nacos 注册中心的实现。

Nacos服务安装与启动

安装地址: https://github.com/alibaba/nacos/releases

  • 本文在Windows环境测试,下载zip版,解压。
  • 配置conf目录下的application.properties文件,配置nacos数据源,端口等。
#*************** Spring Boot Related Configurations ***************#
### Default web context path:
server.servlet.contextPath=/nacos
### Default web server port:
server.port=8848

#*************** Network Related Configurations ***************#
### If prefer hostname over ip for Nacos server addresses in cluster.conf:
# nacos.inetutils.prefer-hostname-over-ip=false

### Specify local server's IP:
# nacos.inetutils.ip-address=



#*************** Config Module Related Configurations ***************#
### If user MySQL as datasource:
spring.datasource.platform=mysql

### Count of DB:
db.num=1

### Connect URL of DB:
db.url.0=jdbc:mysql://127.0.0.1:3306/nacos?serverTimezone=UTC&characterEncoding=utf8
db.user=root
db.password=123456


#*************** Naming Module Related Configurations ***************#
### Data dispatch task execution period in milliseconds:
# nacos.naming.distro.taskDispatchPeriod=200

### Data count of batch sync task:
# nacos.naming.distro.batchSyncKeyCount=1000

### Retry delay in milliseconds if sync task failed:
# nacos.naming.distro.syncRetryDelay=5000

初始化数据库,脚本位于conf目录下nacos-mysql.sql

启动nacos服务,在cmd中执行bin目录下startup.cmd:

D:>cd nacos/bin

D:nacosbin>startup.cmd

     ,--.
    ,--.'|
  ,--,: : | Nacos 1.2.1
,`--.'`| ' :     ,---. Running in stand alone mode, All function modules
|  : : | |    '  ,'  .--.--.  Port: 8848
:  |   | : ,--.--.   ,---. /  /  | / /  '  Pid: 20700
|  : ' '; | /      /   .  ; ,. :| : /`./  Console: http://10.118.37.75:8848/nacos/index.html
'  ' ;.  ;.--. .-. | /  / ''  | |: :| : ;_
|  | |   | __/: . ..  ' / '  | .; :    `.   https://nacos.io
'  : | ; .' ," .--.; |'  ; :__|  :  | `----.  
|  | '`--' / / ,. |'  | '.'|   / / /`--' /
'  : |   ; :  .'    :  : `----' '--'.   /
;  |.'   | ,   .-./   /      `--'---'
'---'    `--`---'   `----'

2020-05-07 16:09:06,639 INFO Bean 'org.springframework.security.config.annotation.configuration.ObjectPostProcessorConfiguration' of type [org.springframework.security.config.annotation.configuration.ObjectPostProcessorConfiguration$$EnhancerBySpringCGLIB$$d2a494f3] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)

2020-05-07 16:09:06,713 INFO Bean 'objectPostProcessor' of type [org.springframework.security.config.annotation.configuration.AutowireBeanFactoryObjectPostProcessor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)

2020-05-07 16:09:06,715 INFO Bean 'org.springframework.security.access.expression.method.DefaultMethodSecurityexpressionHandler@2de56eb2' of type [org.springframework.security.access.expression.method.DefaultMethodSecurityexpressionHandler] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)

2020-05-07 16:09:06,717 INFO Bean 'org.springframework.security.config.annotation.method.configuration.GlobalMethodSecurityConfiguration' of type [org.springframework.security.config.annotation.method.configuration.GlobalMethodSecurityConfiguration$$EnhancerBySpringCGLIB$$f77937a5] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)

2020-05-07 16:09:06,721 INFO Bean 'methodSecuritymetadataSource' of type [org.springframework.security.access.method.DelegatingMethodSecuritymetadataSource] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)

2020-05-07 16:09:07,176 INFO Tomcat initialized with port(s): 8848 (http)

2020-05-07 16:09:07,280 INFO Root WebApplicationContext: initialization completed in 2308 ms

2020-05-07 16:09:16,998 INFO Initializing ExecutorService 'applicationTaskExecutor'

2020-05-07 16:09:17,138 INFO Adding welcome page: class path resource [static/index.html]

2020-05-07 16:09:17,390 INFO Creating filter chain: Ant [pattern='*, postman-token = fc010815-8e7b-4e11-9fed-3d061f388faf, host = localhost:8080, accept-encoding = gzip, deflate, br, connection = keep-alive, content-length = 49
【请求方法】:String com.example.demo.controller.UserController.create(UserDTO)
【请求参数】:[UserDTO(id=null, name=zhangsan, phone=17751033130, sex=1)]
2020-05-08 16:05:14.004 WARN 12544 --- [nio-8080-exec-4] com.zaxxer.hikari.pool.Poolbase     : HikariPool-1 - Failed to validate connection com.mysql.cj.jdbc.ConnectionImpl@2bacd020 (No operations allowed after connection closed.). Possibly consider using a shorter maxLifetime value.
2020-05-08 16:05:14.008 WARN 12544 --- [nio-8080-exec-4] com.zaxxer.hikari.pool.Poolbase     : HikariPool-1 - Failed to validate connection com.mysql.cj.jdbc.ConnectionImpl@5283f4ad (No operations allowed after connection closed.). Possibly consider using a shorter maxLifetime value.
2020-05-08 16:05:14.009 WARN 12544 --- [nio-8080-exec-4] com.zaxxer.hikari.pool.Poolbase     : HikariPool-1 - Failed to validate connection com.mysql.cj.jdbc.ConnectionImpl@1fe3130d (No operations allowed after connection closed.). Possibly consider using a shorter maxLifetime value.
2020-05-08 16:05:14.010 WARN 12544 --- [nio-8080-exec-4] com.zaxxer.hikari.pool.Poolbase     : HikariPool-1 - Failed to validate connection com.mysql.cj.jdbc.ConnectionImpl@11977567 (No operations allowed after connection closed.). Possibly consider using a shorter maxLifetime value.
2020-05-08 16:05:14.011 WARN 12544 --- [nio-8080-exec-4] com.zaxxer.hikari.pool.Poolbase     : HikariPool-1 - Failed to validate connection com.mysql.cj.jdbc.ConnectionImpl@641256c2 (No operations allowed after connection closed.). Possibly consider using a shorter maxLifetime value.
2020-05-08 16:05:14.013 WARN 12544 --- [nio-8080-exec-4] com.zaxxer.hikari.pool.Poolbase     : HikariPool-1 - Failed to validate connection com.mysql.cj.jdbc.ConnectionImpl@29f9f071 (No operations allowed after connection closed.). Possibly consider using a shorter maxLifetime value.
2020-05-08 16:05:14.015 WARN 12544 --- [nio-8080-exec-4] com.zaxxer.hikari.pool.Poolbase     : HikariPool-1 - Failed to validate connection com.mysql.cj.jdbc.ConnectionImpl@2e05f538 (No operations allowed after connection closed.). Possibly consider using a shorter maxLifetime value.
2020-05-08 16:05:14.016 WARN 12544 --- [nio-8080-exec-4] com.zaxxer.hikari.pool.Poolbase     : HikariPool-1 - Failed to validate connection com.mysql.cj.jdbc.ConnectionImpl@41391d2 (No operations allowed after connection closed.). Possibly consider using a shorter maxLifetime value.
2020-05-08 16:05:14.017 WARN 12544 --- [nio-8080-exec-4] com.zaxxer.hikari.pool.Poolbase     : HikariPool-1 - Failed to validate connection com.mysql.cj.jdbc.ConnectionImpl@72c163d4 (No operations allowed after connection closed.). Possibly consider using a shorter maxLifetime value.
2020-05-08 16:05:14.019 WARN 12544 --- [nio-8080-exec-4] com.zaxxer.hikari.pool.Poolbase     : HikariPool-1 - Failed to validate connection com.mysql.cj.jdbc.ConnectionImpl@145d7f85 (No operations allowed after connection closed.). Possibly consider using a shorter maxLifetime value.
2020-05-08 16:05:14.545 DEBUG 12544 --- [nio-8080-exec-4] c.example.demo.mapper.UserMapper.insert : ==> Preparing: INSERT INTO user ( name, sex, phone, create_time, enable, version ) VALUES ( ?, ?, ?, ?, ?, ? ) 
2020-05-08 16:05:14.548 DEBUG 12544 --- [nio-8080-exec-4] c.example.demo.mapper.UserMapper.insert : ==> Parameters: zhangsan(String), MAN(String), 17751033130(String), 2020-05-08T16:05:13.995(LocalDateTime), true(Boolean), 1(Long)
2020-05-08 16:05:14.686 DEBUG 12544 --- [nio-8080-exec-4] c.example.demo.mapper.UserMapper.insert : <==  Updates: 1
2020-05-08 16:05:14.697 INFO 12544 --- [nio-8080-exec-4] com.example.demo.config.LogAspect    : 
 执行结果:
【响应结果】:"ok"
【执行耗时】:701毫秒

到此这篇关于SpringCloud集成Nacos的使用小结的文章就介绍到这了,更多相关SpringCloud集成Nacos内容请搜索考高分网以前的文章或继续浏览下面的相关文章希望大家以后多多支持考高分网!

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/129812.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号