Spring lazy loading and dubbo client verification


Dubbo's service dependency check at startup is to judge whether the remote call is successful and whether the object can be instantiated successfully when the object is instantiated.
Parameters are configurable.
If the dependent service is not provided when the project starts, the consumer cannot start either.




If spring is configured in lazy loading form, that is, when the server starts, the object is not instantiated.



When the object is actually used, instantiate it. If check="true", the service is not provided, and an exception will be thrown immediately. If check="false", if the service is not provided, a reference will be returned. When the service is provided, it will be automatically connected.

Service dependency checks, which can be at startup of a service or all services or registries.
The test class is as follows:



Test result:


The line number in the above figure represents which line actually throws the exception.
33: spring container start
35: get instance
36: call service

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327047925&siteId=291194637