Tag Archives: nacos

[Solved] nacos Startup Error: nested exception is java.lang.RuntimeException: java.lang.RuntimeException: [db-load-error

1. Error reporting steps
I. Download nacos official package
Nacos Quick Start
2. decompress

3. to open
startup.cmd
4. report an error

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:156)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:544)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:744)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:391)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:312)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1204)
at com.alibaba.nacos.Nacos.main(Nacos.java:35)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:108)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:58)
at org.springframework.boot.loader.PropertiesLauncher.main(PropertiesLauncher.java:467)
Caused by: org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
......
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'authFilterRegistration' defined in class path resource [com/alibaba/nacos/core/auth/AuthConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.web.servlet.FilterRegistrationBean]: Factory method 'authFilterRegistration' threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'authFilter': Unsatisfied dependency expressed through field 'authManager'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'nacosAuthManager': Unsatisfied dependency expressed through field 'authenticationManager'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'nacosAuthConfig': Unsatisfied dependency expressed through field 'userDetailsService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'nacosUserDetailsServiceImpl': Unsatisfied dependency expressed through field 'userPersistService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'externalUserPersistServiceImpl': Unsatisfied dependency expressed through field 'persistService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'externalStoragePersistServiceImpl': Invocation of init method failed; nested exception is java.lang.RuntimeException: java.lang.RuntimeException: [db-load-error]load jdbc.properties error
......
Caused by: java.lang.RuntimeException: [db-load-error]load jdbc.properties error
at com.alibaba.nacos.config.server.service.datasource.ExternalDataSourceServiceImpl.init(ExternalDataSourceServiceImpl.java:109)
at com.alibaba.nacos.config.server.service.datasource.DynamicDataSource.getDataSource(DynamicDataSource.java:55)
... 166 common frames omitted
org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:156) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:544) at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:744) at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:391) at org.springframework.boot.SpringApplication.run(SpringApplication.java:312) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1204) at com.alibaba.nacos.Nacos.main(Nacos.java:35) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49) at org.springframework.boot.loader.Launcher.launch(Launcher.java:108) at org.springframework.boot.loader.Launcher.launch(Launcher.java:58) at org.springframework.boot.loader.PropertiesLauncher.main(PropertiesLauncher.java:467) Caused by: org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat ...... Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'authFilterRegistration' defined in class path resource [com/alibaba/nacos/core/auth/AuthConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.web.servlet.FilterRegistrationBean]: Factory method 'authFilterRegistration' threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'authFilter': Unsatisfied dependency expressed through field 'authManager'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'nacosAuthManager': Unsatisfied dependency expressed through field 'authenticationManager'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'nacosAuthConfig': Unsatisfied dependency expressed through field 'userDetailsService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'nacosUserDetailsServiceImpl': Unsatisfied dependency expressed through field 'userPersistService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'externalUserPersistServiceImpl': Unsatisfied dependency expressed through field 'persistService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'externalStoragePersistServiceImpl': Invocation of init method failed; nested exception is java.lang.RuntimeException: java.lang.RuntimeException: [db-load-error]load jdbc.properties error ...... Caused by: java.lang.RuntimeException: [db-load-error]load jdbc.properties error at com.alibaba.nacos.config.server.service.datasource.ExternalDataSourceServiceImpl.init(ExternalDataSourceServiceImpl.java:109) at com.alibaba.nacos.config.server.service.datasource.DynamicDataSource.getDataSource(DynamicDataSource.java:55) ... 166 common frames omitted
org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:156)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:544)
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141)
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:744)
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:391)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:312)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1204)
        at com.alibaba.nacos.Nacos.main(Nacos.java:35)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49)
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:108)
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:58)
        at org.springframework.boot.loader.PropertiesLauncher.main(PropertiesLauncher.java:467)
Caused by: org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
      ......

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'authFilterRegistration' defined in class path resource [com/alibaba/nacos/core/auth/AuthConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.web.servlet.FilterRegistrationBean]: Factory method 'authFilterRegistration' threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'authFilter': Unsatisfied dependency expressed through field 'authManager'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'nacosAuthManager': Unsatisfied dependency expressed through field 'authenticationManager'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'nacosAuthConfig': Unsatisfied dependency expressed through field 'userDetailsService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'nacosUserDetailsServiceImpl': Unsatisfied dependency expressed through field 'userPersistService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'externalUserPersistServiceImpl': Unsatisfied dependency expressed through field 'persistService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'externalStoragePersistServiceImpl': Invocation of init method failed; nested exception is java.lang.RuntimeException: java.lang.RuntimeException: [db-load-error]load jdbc.properties error
 
          ......
     
Caused by: java.lang.RuntimeException: [db-load-error]load jdbc.properties error
        at com.alibaba.nacos.config.server.service.datasource.ExternalDataSourceServiceImpl.init(ExternalDataSourceServiceImpl.java:109)
        at com.alibaba.nacos.config.server.service.datasource.DynamicDataSource.getDataSource(DynamicDataSource.java:55)
        ... 166 common frames omitted

 

2. Solution
1. look at the official documentation (or have to look at the official documentation), use
startup.cmd -m standalone to perform a stand-alone startup
2. Cluster deployment

[Solved] nacos Error: Client not connected,current status:STARTING,StatusRuntimeException

Nacos client connection operation 9848 grpc connection error of Nacos 2.0

After Nacos Server 2.0

Nacos version 2.0 adds a new gRPC communication method compared to 1.X, so 2 additional ports are needed. The new ports are automatically generated by performing a certain offset from the configured master port (server.port).
Port Offset from the master port Description
9848 1000 Client gRPC request server port for clients to initiate connections and requests to the server
9849 1001 Server-side gRPC request server port, used for synchronization between services, etc.

After Nacos client 2.0 is connected through grpc, you cannot use Nacos server version below 2.0

serverInfo.getServerPort() + rpcPortOffset() Port offset 1000
Perform serverCheck operation 
Report an error.
java.util.concurrent.ExecutionException: com.alibaba.nacos.shaded.io.grpc.StatusRuntimeException: UNAVAILABLE: io exception
Error: RpcClient currentConnection is null
Caused by: ErrCode:-401, ErrMsg:Client not connected,current status:STARTING

Solution: use a lower version of Nacos client

How to Solve Nacos startup error

Error 1:

Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerExcepti

Solution:
Open the startup file, and different operating systems open different files. Open startup.cmd on windows, open startup.sh for others, find set MODE, and change it to standalone mode.

Error 2:

Error creating bean with name ‘memoryMonitor’ defined in URL [jar: File:/D:/Nacos/nacos203/target/Nacos server. Jar!/boot-inf/lib/nacos-config-2.0.3. Jar
Solution:

Database connection If there is a problem, the correction method is as follows:
open the application.properties file in the nacos/conf/ folder , find the database connection address, pay attention to whether there is &serverTimezone=UTC after it, and add it if not.
db.url.0=jdbc:mysql: …/lamp_nacos?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true &serverTimezone=UTC

Server check fail, please check server 192.168.11.13 ,port 9848 is available , error ={}

Nacos is started on 192.168.11.13, and the access is normal
the local server is started on 192.168.11.11, and the startup log reports an error
server check fail, please check server 192.168.11.13, port 9848 is available, error = {}

2021-10-09 17:33:16.178 ERROR 21512 --- [           main] c.a.n.c.remote.client.grpc.GrpcClient    : Server check fail, please check server 192.168.11.13 ,port 9848 is available , error ={}

java.util.concurrent.TimeoutException: Waited 3000 milliseconds (plus 731800 nanoseconds delay) for com.alibaba.nacos.shaded.io.grpc.stub.ClientCalls$GrpcFuture@157ec23b[status=PENDING, info=[GrpcFuture{clientCall={delegate={delegate=ClientCallImpl{method=MethodDescriptor{fullMethodName=Request/request, type=UNARY, idempotent=false, safe=false, sampledToLocalTracing=true, requestMarshaller=com.alibaba.nacos.shaded.io.grpc.protobuf.lite.ProtoLiteUtils$MessageMarshaller@60d6fdd4, responseMarshaller=com.alibaba.nacos.shaded.io.grpc.protobuf.lite.ProtoLiteUtils$MessageMarshaller@66f28a1f, schemaDescriptor=com.alibaba.nacos.api.grpc.auto.RequestGrpc$RequestMethodDescriptorSupplier@60a19573}}}}}]]
	at com.alibaba.nacos.shaded.com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:508)
	at com.alibaba.nacos.common.remote.client.grpc.GrpcClient.serverCheck(GrpcClient.java:146)
	at com.alibaba.nacos.common.remote.client.grpc.GrpcClient.connectToServer(GrpcClient.java:268)
	at com.alibaba.nacos.common.remote.client.RpcClient.start(RpcClient.java:395)
	at com.alibaba.nacos.client.config.impl.ClientWorker$ConfigRpcTransportClient.ensureRpcClient(ClientWorker.java:924)
	at com.alibaba.nacos.client.config.impl.ClientWorker$ConfigRpcTransportClient.getOneRunningClient(ClientWorker.java:1087)
	at com.alibaba.nacos.client.config.impl.ClientWorker$ConfigRpcTransportClient.queryConfig(ClientWorker.java:979)
	at com.alibaba.nacos.client.config.impl.ClientWorker.getServerConfig(ClientWorker.java:407)
	at com.alibaba.nacos.client.config.NacosConfigService.getConfigInner(NacosConfigService.java:166)
	at com.alibaba.nacos.client.config.NacosConfigService.getConfig(NacosConfigService.java:94)
	at com.alibaba.cloud.nacos.client.NacosPropertySourceBuilder.loadNacosData(NacosPropertySourceBuilder.java:85)
	at com.alibaba.cloud.nacos.client.NacosPropertySourceBuilder.build(NacosPropertySourceBuilder.java:73)
	at com.alibaba.cloud.nacos.client.NacosPropertySourceLocator.loadNacosPropertySource(NacosPropertySourceLocator.java:199)
	at com.alibaba.cloud.nacos.client.NacosPropertySourceLocator.loadNacosDataIfPresent(NacosPropertySourceLocator.java:186)
	at com.alibaba.cloud.nacos.client.NacosPropertySourceLocator.loadNacosConfiguration(NacosPropertySourceLocator.java:158)
	at com.alibaba.cloud.nacos.client.NacosPropertySourceLocator.loadSharedConfiguration(NacosPropertySourceLocator.java:116)
	at com.alibaba.cloud.nacos.client.NacosPropertySourceLocator.locate(NacosPropertySourceLocator.java:101)
	at org.springframework.cloud.bootstrap.config.PropertySourceLocator.locateCollection(PropertySourceLocator.java:52)
	at org.springframework.cloud.bootstrap.config.PropertySourceLocator.locateCollection(PropertySourceLocator.java:47)
	at org.springframework.cloud.bootstrap.config.PropertySourceBootstrapConfiguration.initialize(PropertySourceBootstrapConfiguration.java:98)
	at org.springframework.boot.SpringApplication.applyInitializers(SpringApplication.java:623)
	at org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:367)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:311)
	at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:140)
	at org.springblade.core.launch.BladeApplication.run(BladeApplication.java:50)
	at com.ht.bms.custom.CustomApplication.main(CustomApplication.java:31)

Although an error is reported, the service can be started normally. The problem is that when the local server calls other services registered in Nacos, it cannot be called after timeout

But other colleagues started the service on their computer and reported no error.

The problem has been solved:
check whether the Nacos server 8848884998489849 is open to these ports. If the docker is started, the ports need to be exposed.
when the ports are exposed and open, there are still problems. I modified the configuration of the idea. The problem is solved:
configuration before modification:

After modification:

the JRE is changed to the JRE installed locally instead of the JRE provided by idea
in addition, the short command line is also modified

The error is not reported when restarting. It is normal, but the configuration is changed back, and the error is still not reported when restarting. It is strange
it may be due to the cache
have a nice work!

springcloud alibaba Integrating nacos reports errors: create config service error!properties=NacosConfigPropertie

Solution:

First, check whether the YML file is configured

spring    
    cloud:
        nacos:
          discovery:
            server-addr: 127.0.0.1:8848
      application:
        name: gulimall-member

If the configuration is completed, check whether the POM file references the configuration center

        <dependency>
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
        </dependency>

If so, just comment it out.

Problem reason: when Nacos config is used for unified configuration management, the bootstrap.properties configuration file is used to initialize the context when starting the springboot project.

When using the unified configuration of springcloudconfig, the loading order of spring boot configuration files is bootstrap.properties – & gt; bootstrap.yml -> application.properties -> Application.yml, where bootstrap.properties is configured as the highest priority.

Therefore, an error is reported if the properties file is not found during configuration.

If you need to use the Nacos configuration center, on the premise of referencing the above dependencies, you need to add the bootstrap.properties file in the resource directory, configure the service name, Nacos address and port number, and restart the service.

spring.application.name=gulimall-coupon
spring.cloud.nacos.config.server-addr=127.0.0.1:8848

 

Solution to the problem of failure to elect leaders when offline service is reported in Nacos

Problem description

When there are multiple instances of a micro service in the Nacos registry, click an instance to go offline and report an error

caused: errCode: 500, errMsg: do metadata operation failed ;
caused: com.alibaba.nacos.consistency.exception.ConsistencyException: com.alibaba.nacos.core.distributed.raft.exception.NoLeaderException: The Raft Group [naming_instance_metadata] did not find the Leader node;
caused: com.alibaba.nacos.core.distributed.raft.exception.NoLeaderException: The Raft Group [naming_instance_metadata] did not find the Leader node;

Solution

Nacos uses the raft algorithm to calculate the leader and will record the cluster address started last time. Therefore, when the IP address of our own server changes (especially the students started locally when we study, because sometimes our network environment will change… WiFi, so the IP address often changes), the cluster address recorded by raft will become invalid, If there is a problem with the selected leader, just delete the protocol folder under the data folder under the root directory of Nacos.

Error creating bean with name ‘servletEndpointRegistrar‘ defined in class path resource

The errors encountered in writing as service items today are shown below. I only know that the creation of error creating bean with name ‘servletendpointregistrar’ defined in class path resource failed. I also found some solutions on the Internet. The most common solutions are that there is a lack of JDBC dependency, or that the database configuration file is wrong. I also compared the database, There is no lack of JDBC dependency, which shows that my database and dependency are correct. I compared other service services and found that more configuration files were introduced into the configuration file

[${project.name}] 2021-09-10 23:21:44,213 ERROR [localhost-startStop-1][Jdk14Logger.java:87] - Error starting Tomcat context. Exception: org.springframework.beans.factory.UnsatisfiedDependencyException. Message: Error creating bean with name 'servletEndpointRegistrar' defined in class path resource [org/springframework/boot/actuate/autoconfigure/endpoint/web/ServletEndpointManagementContextConfiguration.class]: Unsatisfied dependency expressed through method 'servletEndpointRegistrar' parameter 0; nested exception is org.springframework.boot.context.properties.ConfigurationPropertiesBindException: Error creating bean with name 'management.endpoints.web-org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties': Could not bind properties to 'WebEndpointProperties' : prefix=management.endpoints.web, ignoreInvalidFields=false, ignoreUnknownFields=true; nested exception is org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'management.endpoints.web.exposure' to org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties$Exposure
[${project.name}] 2021-09-10 23:21:44,240 WARN [main][Jdk14Logger.java:87] - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
[${project.name}] 2021-09-10 23:21:44,241 INFO [main][DubboGenericServiceFactory.java:159] - The Dubbo GenericService ReferenceBeans are destroying...
[${project.name}] 2021-09-10 23:21:44,245 INFO [main][Jdk14Logger.java:87] - class org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor was destroying!

My Nacos profile is

#HTTP format configuration spring:
http:
  encoding:
    charset: UTF8
    force: true
    enabled: true
  messages:
    encoding: UTF8
#tomcat header information (user ip and access protocol) and access path configuration
server:
  tomcat:
    remote_ip_header: xforwardedfor
    protocol_header: xforwardedproto
  servlet:
    contextpath: /lifly
  useforwardheaders: true

#Service monitoring and management configuration, operation and maintenance related
management:
  endpoints:
    web:
      exposure:
      include: refresh,health,info,env

This configuration file defines the user IP and access path, as well as some configuration files related to service monitoring, management and operation and maintenance. However, the remote call is not used in the service, but I introduced this configuration file. The reason for my error is this, so I recorded it
My bootstrap.yml configuration file is as follows:

server:
  port: 56050 
nacos:
  server:
    addr: 127.0.0.1:8848
spring:
  application:
    name: transaction-service
#  main:
#    allow-bean-definition-overriding: true # Spring Boot 2.1 
  cloud:
    nacos:
      discovery:
        server-addr: 127.0.0.1:8848
#        server-addr: ${nacos.server.addr}
        namespace: 339eea59-f7f4-44d0-a3fa-9f1f85bd5b4f
#        cluster-name: COMMON_GROUP
      config:
        server-addr: 127.0.0.1:8848
#        server-addr: ${nacos.server.addr} 
        file-extension: yaml
        namespace: 339eea59-f7f4-44d0-a3fa-9f1f85bd5b4f  
        group: DEFAULT_GROUP 
        ext-config:
          -
            refresh: true
            data-id: spring-boot-http.yaml # spring boot http
            group: COMMON_GROUP 
#          -
#            refresh: true
#            data-id: spring-boot-starter-druid.yaml # spring boot starter druid
#            group: COMMON_GROUP 
#          -
#            refresh: true
#            data-id: spring-boot-mybatis-plus.yaml # spring boot mybatisplus
#            group: COMMON_GROUP 
#          - refresh: true
#            data-id: spring-boot-redis.yaml 
#            group: COMMON_GROUP 
  datasource:
    driver-class-name: com.mysql.jdbc.Driver
    url: jdbc:mysql://localhost:3306/huiminpay_transaction?useUnicode=true&useSSL=false
    #  url: jdbc:mysql://localhost:3306/huiminpay_merchant_service?characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true&useUnicode=true
    username: root
    password: 1234
mybatis-plus:
  type-aliases-package: com.huiminpay.transaction.entity
  mapper-locations: classpath:/mapper/*.xml

dubbo:
  scan:
    # dubbo 
    base-packages: com.huiminpay
  protocol:
    # dubbo 协议
    name: dubbo
    port: 20893
  registry:
    address: nacos://127.0.0.1:8848
  application:
    qos:
      port: 22250 # dubbo qos
  consumer:
    check: false
    timeout: 3000
    retries: -1

logging:
  config: classpath:log4j2.xml

I commented out the import file and the project started. Record it again, and I hope it will be helpful to you. Comment out the following import file

 ext-config:
          -
            refresh: true
            data-id: spring-boot-http.yaml # spring boot http set
            group: COMMON_GROUP 

After Nacos started, the client worker log was printed all the time

After Nacos started, the client worker log was printed all the time

Phenomenon

Print the clientworker log all the time

2020-08-24 00:57:30.977 INFO  [12932] --- [.cn_8848-public] c.a.n.client.config.impl.ClientWorker    : [fixed-nacos.itlym.cn_8848-public] [data-received] dataId=common.yml, group=DEFAULT_GROUP, tenant=public, md5=8c191cace81179b01fb745b5d027c1c8, content=xxx
2020-08-24 00:57:30.989 INFO  [12932] --- [.cn_8848-public] c.a.n.client.config.impl.ClientWorker    : [fixed-nacos.itlym.cn_8848-public] [data-received] dataId=sms-center.yml, group=DEFAULT_GROUP, tenant=public, md5=f12bc945ba0c1d39f3dea2e0977db712, content=xxx
...

Cause analysis

Root cause

Having seen the source code of Nacos before, Nacos will check whether the configuration items are consistent with the server configuration items every 10ms. If not, it will pull the latest configuration from the server therefore, if the MD5 algorithms of Nacos client and Nacos server are different, it will lead to misjudgment, thus constantly refreshing and printing the client worker logs.

Direct cause

My Nacos server is 1.3, and the client uses spring cloud Alibaba. Version . Click to find that the Nacos client version is 1.2

			<dependency>
                <groupId>com.alibaba.cloud</groupId>
                <artifactId>spring-cloud-alibaba-dependencies</artifactId>
                <version>2.2.1.RELEASE</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>

Here, the spring-cloud-alibaba-dependencies‘s official website and warehouse have not been updated for a long time, which is easy to make complaints about users and waste a lot of investigation time.

Other possible reasons

The public is set in the namespace. See the Nacos GitHub

At this time, the best way to solve this problem is not to set the namespace. Otherwise, when Nacos releases a new version, it may be 1.4

Solution

Method 1:

Change the version of client and Nacos server to the same, as follows

client:
<dependency>
    <groupId>com.alibaba.cloud</groupId>
    <artifactId>spring-cloud-alibaba-dependencies</artifactId>
    <version>${spring-cloud-alibaba.version}</version>
    <type>pom</type>
    <scope>import</scope>
    <exclusions>
    <exclusion>
        <artifactId>com.alibaba.nacos</artifactId>
        <groupId>nacos-client</groupId>
    </exclusion>
    </exclusions>
</dependency>
<dependency>
    <groupId>com.alibaba.nacos</groupId>
    <artifactId>nacos-client</artifactId>
    <version>1.3.2</version>
</dependency>

Method 2:

Because spring cloud Alibaba dependencies leaves the gap of properties specified version (default < nacos.client.version> 1.2.1)
so you only need to add

<properties>
	<nacos.client.version>1.2.1</nacos.client.version>
</properties>

Note: if spring cloud starter Nacos config is introduced, it can’t be avoided by this scheme, because ‘spring cloud Alibaba dependencies’ has hard coding problems. When importing, you should actively specify the version.

			 <dependency>
                <groupId>com.alibaba.cloud</groupId>
                <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
                <version>1.3.0</version>
            </dependency>

Method 3 (middleware upgrade scheme suitable for existing system):

Download the Nacos client Version 1.2.1 code, modify its md5util package path to a new one, and then re publish it to the local or private warehouse.