Category Archives: How to Fix

Python UnboundLocalError: local variable ‘num’ referenced before assignment

The source code

num = 1

def test():
    num += 1
    return num

print(test())

Error details

Possible reasons for
Undeclared variables appear in Python, and PY finds the scope of a variable by following a simple rule: If there is an assignment to a variable within a function, the variable is considered local and can be modified normally. However, if the variable is not defined inside the function, and there is no variable scope declaration (to call the external variable), the program cannot find the corresponding variable inside the function, so the error message of undefined variable will appear.
The solution
Declare variables as global variables, use global keywords when calling, and you can access them normally. The correct code is as follows:

num = 1

def test():
    global num
    num = num + 1
    return num

print(test())    # output is:2

Golang timer function executes a function every few minutes

Delay calling AfterFunc

go function()
 
 
func function() {
	// TODO Specific logic
 
	// executed every 5 minutes, recursively calling itself
	time.AfterFunc(5*time.Minute, function)
}

Tickers

package main

import "time"
import "fmt"

func main() {

    // The mechanism of a punter and a timer is somewhat similar: a channel is used to send data. </span
    // Here we use the built-in `range` on this channel to iterate over the values every
    // The value sent once in 500ms.
    ticker := time.NewTicker(time.Millisecond * 500)
    go func() {
        for t := range ticker.C {
            fmt.Println("Tick at", t)
        }
    }()

    // The punctuator can be stopped in the same way as the timer. </span
    // Once a punctuation is stopped, it will no longer be able to receive values from its channel. 
    // We will stop this punter after 1600ms of running.
    time.Sleep(time.Millisecond * 1600)
    ticker.Stop()
    fmt.Println("Ticker stopped")
}

When we run this program, the dotter will do 3 times before we stop it.

go run tickers.go
Tick at 2012-09-23 11:29:56.487625 -0700 PDT
Tick at 2012-09-23 11:29:56.988063 -0700 PDT
Tick at 2012-09-23 11:29:57.488076 -0700 PDT
Ticker stopped

[Solved] #command-line-arguments .\main.go:5:4: no new variables on left side of :=

# command-line-arguments
.\main.go:5:4: no new variables on left side of :=
package main
import “fmt”
func main(){
var b int;
b := 1;
fmt.Println(b);
}

The correct way to write it: remove the : or add a new variable
package main
import “fmt”
func main(){
var b int;
b,a := 1,2;
fmt.Println(b,a);
}
// No compile error is generated at this point because a new variable is declared, because := is a declaration statement

 

How to get the current time in java time string

How to get the current time by Java
and convert it into java.sql.date format.

		long l = System.currentTimeMillis();
		//new date pair
		Date date = new Date(l);
		//convert to date output format
		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		System.out.println(dateFormat.format(date)); 
		
		String response = dateFormat.format(date).replaceAll("[[\\s-:punct:]]","");
		System.out.println("response="+response);

2021-05-07 09:35:47response=202105

Ant Design proformdigit fieldprops limits the number of decimal places entered

Proformdigit uses min limit to input the minimum value, Max limit to input the maximum value, fieldprops limit to input the decimal places

Keep two decimal places fieldprops = {precision: 2}}

<ProFormDigit 
	label="InputNumber" 
	name="num"
	min={1}
	max={22}
	fieldProps={{ precision: 2 }}
/>

fieldProps={{ precision: 0 }}

<ProFormDigit 
	label="InputNumber" 
	name="num"
	min={1}
	max={22}
	fieldProps={{ precision: 0 }}
/>

[Solved] org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.zyh.springboot.

Super detailed – springboot + mybatisplus can’t find a solution to mapper using XML
org.apache.ibatis.binding.bindingexception: invalid bound statement (not found): com.zyh.springboot.mapper.bowmapper.findlist
1. First, please look at my project directory, and my XML file is placed under mapper/XML

2, Add the following content in application.yml.
in fact, many students added mybatis plus at the beginning of the project, then add
mapper locations: classpath/COM/zyh/springboot/mapper/XML /. XML at the end.
note: there is no link between packages, such as com.zyh.springboot, which is incorrect
you can see that my mapper locations path is my XML path

#print sql code
mybatis-plus:
  configuration:
    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
    map-underscore-to-camel-case: true  
  type-aliases-package: com.zyh.springboot.entity
  mapper-locations: classpath*:/com/zyh/springboot/mapper/xml/*.xml

3. Add an XML resource to pom.xml. This step is very important. If you don’t add it, you will always report an error.
regardless of the path, you just need to fill in * /. XML

<build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
        <resources>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.xml</include>
                </includes>
            </resource>
        </resources>
    </build>

4. Save the code, run the environment, and you can find the mapper

[Solved] RuntimeError: Trying to backward through the graph a second time…

RuntimeError: Trying to backward through the graph a second time, but the buffers have already been freed. Specify retain_graph=True when calling backward the first time.
torch.autograd.backward

torch.autograd.backward(tensors, grad_tensors=None, retain_graph=None, create_graph=False, grad_variables=None)

retain_ graph (bool, optional) – If False, the graph used to compute the grad will be freed. Note that in nearly all cases setting this option to True is not needed and often can be worked around in a much more efficient way.Defaults to the value of create_ graph.create_ graph (bool, optional) – If True, graph of the derivative will be constructed, allowing to compute higher order derivative products.Defaults to False.

retain_ graph = True (when to use it?)

retain_ Graph is a parameter that we can’t use in ordinary times, but we will use it in special cases

    1. when there are two outputs in a network that need to be backwarded respectively: output1. Backward(), output2. Backward(). When there are two losses in a network that need to be backwarded respectively: loss1. Backward(), loss1. Backward(). </ OL> when there are two outputs in a network that need to be backwarded respectively

Take case 2. For example,
if the code is written like this, the parameter at the beginning of the blog will appear:

loss1.backward()
loss2.backward()

Correct code:

loss1.backward(retain_graph=True) #Keep the intermediate arguments after backward.
loss2.backward() # All intermediate variables are freed for the next loop
optimizer.step() # update parameters

retain_ The graph parameter is true to keep the intermediate parameter, so that the backward() of two loss will not affect each other.

Supplement: when two losses of two networks need to be backwarded respectively for backhaul: loss1. Backward(), loss1. Backward()

#The case of two networks requires defining separate optimizers for each of the two networks
optimizer1= torch.optim.SGD(net1.parameters(), learning_rate, momentum,weight_decay)
optimizer2= torch.optim.SGD(net2.parameters(), learning_rate, momentum,weight_decay)
.....
#train Part of the loss return processing
loss1 = loss()
loss2 = loss()

optimizer1.zero_grad() #set the grade to zero
loss1.backward(retain_graph=True) #Keep the intermediate parameters after backward.
optimizer1.step()

optimizer2.zero_grad() #set the grade to zero
loss2.backward()
optimizer2.step()

scheduler = torch.optim.lr_ Scheduler. Steplr (
appendix:

Step explanation

optimizer.zero_ grad()

Initialize the gradient to zero
(because the derivative of loss of a batch with respect to weight is the sum of the derivative of loss with respect to weight of all samples)
corresponding to d_ weights = [0] * n

output = net(inputs)

The predicted value is obtained by forward propagation

loss = Loss(outputs, labels)

Ask for loss

loss.backward()

Back propagation for gradient
corresponding D_ weights = [d_ weights[j] + (label[k] – output ) * input[k][j] for j in range(n)]

optimizer.step()

Update all parameters
corresponding weights = [weights [k] + alpha * D_ weights[k] for k in range(n)]

Using shapely.geometry.polygon to calculate the IOU of any two quadrilaterals

The source is Mr. Bai Xiang of Huazhong University of science and technology.

import numpy as np 
import shapely
from shapely.geometry import Polygon,MultiPoint  #Polygon
 
line1=[2,0,2,2,0,0,0,0,2] #One-dimensional array representation of the coordinates of the four points of the quadrilateral, [x,y,x,y....]
a = np.array(line1).reshape(4, 2) # quadrilateral two-dimensional coordinate representation
poly1 = Polygon(a).convex_hull # python quadrilateral object, will automatically calculate four points, the last four points in the order of: top left bottom right bottom right top left top
print(Polygon(a).convex_hull) # you can print to see if this is the case

 
line2=[1,1,4,1,4,4,1,4]
b=np.array(line2).reshape(4, 2)
poly2 = Polygon(b).convex_hull
print(Polygon(b).convex_hull)
 
union_poly = np.concatenate((a,b))   #Merge two box coordinates to become 8*2
#print(union_poly)
print(MultiPoint(union_poly).convex_hull) # contains the smallest polygon point of the two quadrilaterals
if not poly1.intersects(poly2): #If the two quadrilaterals do not intersect
    iou = 0
else:
    try:
        inter_area = poly1.intersection(poly2).area #intersection area
        print(inter_area)
        #union_area = poly1.area + poly2.area - inter_area
        union_area = MultiPoint(union_poly).convex_hull.area
        print(union_area)
        if union_area == 0:
            iou= 0
        #iou = float(inter_area)/(union_area-inter_area)  #wrong
        iou=float(inter_area)/union_area
        # iou=float(inter_area) /(poly1.area+poly2.area-inter_area)
        # The source code gives two ways to calculate IOU, the first one is: intersection part / area of the smallest polygon containing two quadrilaterals  
        # The second one: intersection/merge (common way to calculate IOU of rectangular box) 
    except shapely.geos.TopologicalError:
        print('shapely.geos.TopologicalError occured, iou set to 0')
        iou = 0
 
print(a)
 
print(iou)

Using UMI plugin keep alive to realize keep alive state storage in UMI Ant Design

Using UMI plugin keep alive to store the keep alive state
1

$ npm install umi-plugin-keep-alive --save
//or
$ yarn add umi-plugin-keep-alive

2. Use

import { KeepAlive } from 'umi'
const contentList = () => {
	return (
		<>
			<KeepAlive 
				name="/About" //Can unload the <KeepAlive> node in the cached state by name
				saveScrollPosition="screen" //automatically saves the scroll position of the shared screen container
				when={true} > //true unloads when cached, false unloads when not cached
				<About/> //Component to save state for
			</KeepAlive>
		</>
	)
}

This function is based on react activation. For more details, please refer to react activation

1093 – You can’t specify target table ‘table’ for update in FROM clause

The general meaning is that you can’t select some values in the table first, and then update the table (in the same statement)

 
A temporary table can be introduced for operation

delete from push_ plans WHERE id in  
(
     select id from  
     (
         select id from push_ plans WHERE   area_ id = 0
         
     ) as t
)  
 

java.lang.IllegalArgumentException: Address 127.0.0.1:5672:5672 seems to contain an unquoted IPv6

 
1. The application error is as follows:

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'rabbitConnectionFactory' defined in class path resource [org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration$RabbitConnectionFactoryCreator.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.amqp.rabbit.connection.CachingConnectionFactory]: Factory method 'rabbitConnectionFactory' threw exception; nested exception is java.lang.IllegalArgumentException: Address 10.231.20.36:5672:5672 seems to contain an unquoted IPv6 address. Make sure you quote IPv6 addresses like so: [2001:db8:85a3:8d3:1319:8a2e:370:7348]

2. Main stack information: illegal parameter exception:


org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'rabbitAnnotationPostProcessor' defined in class path resource [com/XXX/alpha/commons/rabbitmq/RabbitConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.XXX.alpha.commons.rabbitmq.RabbitAnnotationPostProcessor]: Factory method 'rabbitAnnotationPostProcessor' threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'com.XXX.alpha.commons.rabbitmq.RabbitAnnotationPostProcessor': Unsatisfied dependency expressed through field 'rabbitTemplate'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'rabbitTemplate' defined in class path resource [org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration$RabbitTemplateConfiguration.class]: Unsatisfied dependency expressed through method 'rabbitTemplate' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'rabbitConnectionFactory' defined in class path resource [org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration$RabbitConnectionFactoryCreator.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.amqp.rabbit.connection.CachingConnectionFactory]: Factory method 'rabbitConnectionFactory' threw exception; nested exception is java.lang.IllegalArgumentException: Address 10.231.0.36:5672:5672 seems to contain an unquoted IPv6 address. Make sure you quote IPv6 addresses like so: [2001:db8:85a3:8d3:1319:8a2e:370:7348]
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:590)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1247)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1096)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:535)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:495)
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:204)
    at org.springframework.context.support.PostProcessorRegistrationDelegate.registerBeanPostProcessors(PostProcessorRegistrationDelegate.java:236)
    at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:710)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:535)
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:780)
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:412)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:333)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1277)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1265)
    at com.XXX.quality.Application.main(Application.java:42)
    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:48)
    at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
    at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
    at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.XXX.alpha.commons.rabbitmq.RabbitAnnotationPostProcessor]: Factory method 'rabbitAnnotationPostProcessor' threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'com.XXX.alpha.commons.rabbitmq.RabbitAnnotationPostProcessor': Unsatisfied dependency expressed through field 'rabbitTemplate'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'rabbitTemplate' defined in class path resource [org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration$RabbitTemplateConfiguration.class]: Unsatisfied dependency expressed through method 'rabbitTemplate' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'rabbitConnectionFactory' defined in class path resource [org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration$RabbitConnectionFactoryCreator.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.amqp.rabbit.connection.CachingConnectionFactory]: Factory method 'rabbitConnectionFactory' threw exception; nested exception is java.lang.IllegalArgumentException: Address 10.231.0.36:5672:5672 seems to contain an unquoted IPv6 address. Make sure you quote IPv6 addresses like so: [2001:db8:85a3:8d3:1319:8a2e:370:7348]
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:582)
    ... 26 common frames omitted
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'com.XXX.alpha.commons.rabbitmq.RabbitAnnotationPostProcessor': Unsatisfied dependency expressed through field 'rabbitTemplate'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'rabbitTemplate' defined in class path resource [org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration$RabbitTemplateConfiguration.class]: Unsatisfied dependency expressed through method 'rabbitTemplate' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'rabbitConnectionFactory' defined in class path resource [org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration$RabbitConnectionFactoryCreator.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.amqp.rabbit.connection.CachingConnectionFactory]: Factory method 'rabbitConnectionFactory' threw exception; nested exception is java.lang.IllegalArgumentException: Address 10.231.0.36:5672:5672 seems to contain an unquoted IPv6 address. Make sure you quote IPv6 addresses like so: [2001:db8:85a3:8d3:1319:8a2e:370:7348]
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:586)
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:90)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:372)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1341)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireBean(AbstractAutowireCapableBeanFactory.java:312)
    at com.XXX.alpha.commons.rabbitmq.RabbitConfiguration.rabbitAnnotationPostProcessor(RabbitConfiguration.java:30)
    at com.XXX.alpha.commons.rabbitmq.RabbitConfiguration$$EnhancerBySpringCGLIB$$b3552c3d.CGLIB$rabbitAnnotationPostProcessor$1(<generated>)
    at com.XXX.alpha.commons.rabbitmq.RabbitConfiguration$$EnhancerBySpringCGLIB$$b3552c3d$$FastClassBySpringCGLIB$$64ec2440.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
    at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:365)
    at com.XXX.alpha.commons.rabbitmq.RabbitConfiguration$$EnhancerBySpringCGLIB$$b3552c3d.rabbitAnnotationPostProcessor(<generated>)
    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.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
    ... 27 common frames omitted
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'rabbitTemplate' defined in class path resource [org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration$RabbitTemplateConfiguration.class]: Unsatisfied dependency expressed through method 'rabbitTemplate' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'rabbitConnectionFactory' defined in class path resource [org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration$RabbitConnectionFactoryCreator.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.amqp.rabbit.connection.CachingConnectionFactory]: Factory method 'rabbitConnectionFactory' threw exception; nested exception is java.lang.IllegalArgumentException: Address 10.231.0.36:5672:5672 seems to contain an unquoted IPv6 address. Make sure you quote IPv6 addresses like so: [2001:db8:85a3:8d3:1319:8a2e:370:7348]
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:732)
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:474)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1247)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1096)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:535)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:495)
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:251)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1135)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1062)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:583)
    ... 42 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'rabbitConnectionFactory' defined in class path resource [org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration$RabbitConnectionFactoryCreator.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.amqp.rabbit.connection.CachingConnectionFactory]: Factory method 'rabbitConnectionFactory' threw exception; nested exception is java.lang.IllegalArgumentException: Address 10.231.20.36:5672:5672 seems to contain an unquoted IPv6 address. Make sure you quote IPv6 addresses like so: [2001:db8:85a3:8d3:1319:8a2e:370:7348]
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:590)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1247)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1096)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:535)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:495)
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:251)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1135)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1062)
    at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:818)
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:724)
    ... 55 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.amqp.rabbit.connection.CachingConnectionFactory]: Factory method 'rabbitConnectionFactory' threw exception; nested exception is java.lang.IllegalArgumentException: Address 10.231.20.36:5672:5672 seems to contain an unquoted IPv6 address. Make sure you quote IPv6 addresses like so: [2001:db8:85a3:8d3:1319:8a2e:370:7348]
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:582)
    ... 68 common frames omitted
Caused by: java.lang.IllegalArgumentException: Address 10.231.20.36:5672:5672 seems to contain an unquoted IPv6 address. Make sure you quote IPv6 addresses like so: [2001:db8:85a3:8d3:1319:8a2e:370:7348]
    at com.rabbitmq.client.Address.parseHost(Address.java:96)
    at com.rabbitmq.client.Address.parseAddress(Address.java:158)
    at com.rabbitmq.client.Address.parseAddresses(Address.java:173)
    at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.setAddresses(AbstractConnectionFactory.java:281)
    at org.springframework.boot.context.properties.PropertyMapper$Source.to(PropertyMapper.java:304)
    at org.springframework.boot.autoconfigure.amqp.RabbitAutoConfiguration$RabbitConnectionFactoryCreator.rabbitConnectionFactory(RabbitAutoConfiguration.java:110)
    at org.springframework.boot.autoconfigure.amqp.RabbitAutoConfiguration$RabbitConnectionFactoryCreator$$EnhancerBySpringCGLIB$$5f768139.CGLIB$rabbitConnectionFactory$0(<generated>)
    at org.springframework.boot.autoconfigure.amqp.RabbitAutoConfiguration$RabbitConnectionFactoryCreator$$EnhancerBySpringCGLIB$$5f768139$$FastClassBySpringCGLIB$$4bbac420.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
    at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:365)
    at org.springframework.boot.autoconfigure.amqp.RabbitAutoConfiguration$RabbitConnectionFactoryCreator$$EnhancerBySpringCGLIB$$5f768139.rabbitConnectionFactory(<generated>)
    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.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
    ... 69 common frames omitted
2020-02-25 18:25:31.973 [main] DEBUG 

 
  Because spring.rabbitmq.host is configured with a port number

spring.rabbitmq.port=5672  

 
It’s just that rabbitmq thinks it’s the way to write IPv6. From the side, rabbitmq already supports the host configuration of IPv6