Tag Archives: spring cloud Alibaba

[Solved] Seata Error: endpoint format should like ip:port

Abnormal scene

Failed to get available servers: endpoint format should like ip:port


Cause of error

Ensure that the versions are consistent. The server version downloaded by Seata must be consistent with the dependent version introduced by Maven

Locally installed version

I use seata1 locally Version 4.0


Maven import version

The imported version is cloud version 2.2.7, which encapsulates Seata

Correspondence between Seata and cloud


How to solve

Just keep the locally installed version of Seata consistent with the version imported by Maven. After I change the imported version of maven, I can introduce Seata version 1.4.0.

 <!-- https://mvnrepository.com/artifact/io.seata/seata-spring-boot-starter -->
 <dependency>
     <groupId>io.seata</groupId>
     <artifactId>seata-spring-boot-starter</artifactId>
     <version>1.4.0</version>
 </dependency>

Of course, you can also go to the official website of Seata to download the corresponding seata1.3 version to Maven.

[Solved] Feign Error: -‘oauth-client.FeignClientSpecification‘ could not be registered

environment

<spring-boot.version>2.5.3</spring-boot.version>
<spring-cloud.version>2020.0.3</spring-cloud.version>
<spring-cloud-alibaba.version>2021.1</spring-cloud-alibaba.version>

report errors

Errors are reported during project startup, as follows:

2021-12-22 16:55:56.766  WARN 21922 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.support.BeanDefinitionOverrideException: Invalid bean definition with name 'oauth-client.FeignClientSpecification' defined in null: Cannot register bean definition [Generic bean: class [org.springframework.cloud.openfeign.FeignClientSpecification]; scope=; abstract=false; lazyInit=null; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] for bean 'oauth-client.FeignClientSpecification': There is already [Generic bean: class [org.springframework.cloud.openfeign.FeignClientSpecification]; scope=; abstract=false; lazyInit=null; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] bound.
2021-12-22 16:55:56.776  INFO 21922 --- [           main] ConditionEvaluationReportLoggingListener : 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2021-12-22 16:55:56.799 ERROR 21922 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

The bean 'xxx-client.FeignClientSpecification' could not be registered. A bean with that name has already been defined and overriding is disabled.

Action:

Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true

reason

Multiple interfaces in a project use @ feignclient to call the same service, which means that a service can only be used once with @ feignclient.

Solution:

1) Distinguish with ContextID

But I don’t know why it didn’t work

@FeignClient(value = “xxx-server”, contextId = “oauth-client”)
public interface OAuthClientFeignClient {
@GetMapping("/api/v1/oauth-clients/{clientId}")
Result<SysOauthClient> getOAuthClientById(@PathVariable String clientId);
}

2) Add the following code to the application.properties file.

#Allow the existence of multiple Feign calls to the same Service interface
spring.main.allow-bean-definition-overriding=true

3) Add the following code to the application.yml file.

spring:
  main:
    #Allow the existence of multiple Feign calls to the same Service interface
    allow-bean-definition-overriding: true
        The above code enables multiple interfaces to call the same service using @FeignClient.

[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

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

How to Solve “Error db.num is null” when starting Nacos

Nacos startup is divided into stand-alone or cluster. When you start in cluster mode but do not configure the data source that the cluster depends on, the error db.num is null will be reported

Solution

The operation of this paper is based on Windows environment, similar to Linux

Mode 1: single machine mode startup

startup.cmd -m standalone

Start as shown in the figure below:

standalone: independent
at this time, Nacos starts in stand-alone mode

Mode 2: start in cluster mode and configure the data source

Use the conf/nacos-mysql.sql file to initialize the database, and modify the conf/application.properties file to add MySQL support

spring.datasource.platform=mysql
db.num=1
db.url.0=jdbc:mysql://localhost:3306/nacos?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true
db.user=root
db.password=1234

All the above configurations exist in the original configuration. You only need to modify the parameter value
after the modification is successful, start Nacos

startup.bat

Spring Cloud Hoxton.SR9 gateway and reactor-netty 0.9.0.RELEASE is Incompatible [How to Solve]

Spring cloud hoxton.sr9 gateway is not compatible with reactor netty 0.9.0.release

An error occurred when starting the spring cloud Gateway project
runtime

Spring boot version: 2.2.0.release
spring cloud version: Hoxton. SR9
spring cloud Alibaba version: 2.2.1.release

***************************
APPLICATION FAILED TO START
***************************

Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

    org.springframework.cloud.gateway.config.GatewayAutoConfiguration$NettyConfiguration.gatewayHttpClient(GatewayAutoConfiguration.java:675)

The following method did not exist:

    'reactor.netty.resources.ConnectionProvider reactor.netty.resources.ConnectionProvider.elastic(java.lang.String, java.time.Duration, java.time.Duration)'

The method's class, reactor.netty.resources.ConnectionProvider, is available from the following locations:

    jar:file:/E:/apache-maven-3.6.3/repo/io/projectreactor/netty/reactor-netty/0.9.0.RELEASE/reactor-netty-0.9.0.RELEASE.jar!/reactor/netty/resources/ConnectionProvider.class

It was loaded from the following location:

    file:/E:/apache-maven-3.6.3/repo/io/projectreactor/netty/reactor-netty/0.9.0.RELEASE/reactor-netty-0.9.0.RELEASE.jar


Action:

Correct the classpath of your application so that it contains a single, compatible version of reactor.netty.resources.ConnectionProvider


Process finished with exit code 1

Try to upgrade the reactor netty version to 0.9.4. Release
as a result, the spring weblux version is incompatible

***************************
APPLICATION FAILED TO START
***************************

Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

    org.springframework.cloud.gateway.config.GatewayAutoConfiguration$NettyConfiguration.reactorNettyWebSocketClient(GatewayAutoConfiguration.java:803)

The following method did not exist:

    'void org.springframework.web.reactive.socket.client.ReactorNettyWebSocketClient.setHandlePing(boolean)'

The method's class, org.springframework.web.reactive.socket.client.ReactorNettyWebSocketClient, is available from the following locations:

    jar:file:/E:/apache-maven-3.6.3/repo/org/springframework/spring-webflux/5.2.0.RELEASE/spring-webflux-5.2.0.RELEASE.jar!/org/springframework/web/reactive/socket/client/ReactorNettyWebSocketClient.class

It was loaded from the following location:

    file:/E:/apache-maven-3.6.3/repo/org/springframework/spring-webflux/5.2.0.RELEASE/spring-webflux-5.2.0.RELEASE.jar


Action:

Correct the classpath of your application so that it contains a single, compatible version of org.springframework.web.reactive.socket.client.ReactorNettyWebSocketClient


Process finished with exit code 1

Restore the original version, and finally downgrade the spring cloud version to hoxton.sr1. It runs successfully. As a result, a new hole appears, and Nacos has a version incompatibility problem. There is no way to find the official recommended configuration of spring cloud Alibaba, and modify the spring boot, spring cloud, and spring cloud Alibaba versions. It runs successfully

Spring boot version: 2.3.2. Release
spring cloud version: Hoxton. SR8
spring cloud Alibaba version: 2.2.5. Release


Attach the official recommended version address of spring cloud Alibaba
recommended version

Spring cloud Alibaba 2020.0.rc1 does not integrate ribbon error reporting unknownhostexception

The title starts from 3 because other pits have been recorded before

3. Spring cloud Alibaba 2020.0.rc1 does not integrate ribbon error reporting unknownhostexception

3.1 first check whether our notes are correct, and then look at the following

3.2 no ribbon

We can see from the dependency package that spring cloud Alibaba 2020.0.rc1 is not integrated with ribbon, which is not right,

In this version, calling the microservice through resttemplate always prompts that the microservice is not found

3.3 it’s OK to go back to 2.1.4 or manually add the ribbon dependency

When I go back to 2.1.4.release and look at dependency, there is ribbon

The visit is normal

Join ribbon manually

It’s OK, too

Although I don’t know whether to give up the ribbon or forget to add it, I haven’t found any other method and usage to record the time 2021.3.22

How to Fix Error when integrating spring cloud openfeign with spring cloud Alibaba

When learning how to integrate spring cloud with Alibaba, we encountered an openfeign call error

Caused by: java.lang.IllegalStateException: No Feign Client for loadBalancing defined. Did you forget to include spring-cloud-starter-loadbalancer?
	at org.springframework.cloud.openfeign.FeignClientFactoryBean.loadBalance(FeignClientFactoryBean.java:309) ~[spring-cloud-openfeign-core-3.0.0.jar:3.0.0]
	at org.springframework.cloud.openfeign.FeignClientFactoryBean.getTarget(FeignClientFactoryBean.java:335) ~[spring-cloud-openfeign-core-3.0.0.jar:3.0.0]
	at org.springframework.cloud.openfeign.FeignClientFactoryBean.getObject(FeignClientFactoryBean.java:315) ~[spring-cloud-openfeign-core-3.0.0.jar:3.0.0]
	at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:169) ~[spring-beans-5.3.3.jar:5.3.3]
	... 47 common frames omitted

Baidu found that openfeign 3.0.0 built in spring cloud 2020.0.0 conflicts with Nacos framework of spring cloud Alibaba.

Here are two solutions

Methond 1

First add the loadbalancer dependency in pom.xml

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-loadbalancer</artifactId>
</dependency>

Because nacos dependencies containing ribbon dependencies will cause loadbalancer to be invalid, you need to exclude the ribbon dependencies from nacos dependencies.

<dependency>
	<groupId>com.alibaba.cloud</groupId>
	<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
	<exclusions>
		<exclusion>
			<artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
			<groupId>org.springframework.cloud</groupId>
		</exclusion>
	</exclusions>
</dependency>

Method 2

 <!-- spring cloud 2020.0.0built-in openfeign3.0.0 and spring cloud alibaba framework nacos, seata conflict temporary solution - >
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-openfeign</artifactId>
            <version>2.2.6.RELEASE</version>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.cloud</groupId>
                    <artifactId>spring-cloud-starter</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.springframework.cloud</groupId>
                    <artifactId>spring-cloud-openfeign-core</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.springframework.cloud</groupId>
                    <artifactId>spring-cloud-commons</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter</artifactId>
            <version>2.2.6.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-openfeign-core</artifactId>
            <version>2.2.6.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-commons</artifactId>
            <version>2.2.6.RELEASE</version>
        </dependency>