Project scenario:
The error report is reported when the SpringBoot project is started, and the entire process of solving the error is recorded. I hope to give people who see it some solutions and ideas. When encountering such project startup errors, don’t be unable to start and carefully find effective information from the error log. We must firmly believe:There must be a cause when something happens.
Problem description:
Since it is a problem, just post the error log:
Error creating bean with name 'mapperScannerConfigurer' defined in class path resource [com/gwm/tsp/boot/dao/config/datasource/]: Bean instantiation via factory method failed; nested exception is : Failed to instantiate []: Factory method 'mapperScannerConfigurer' threw exception; nested exception is ……
Cause: : Error resolving class. Cause: : Could not resolve type alias 'PlatUserInfoResponse'. Cause: : Cannot find class: PlatUserInfoResponse……
Caused by: : Cannot find class: PlatUserInfoResponse
tat (:200)
tat (:89)
tat (:261)
tat (:116)
t... 46 common frames omitted
Disconnected from the target VM, address: '127.0.0.1:60992', transport: 'socket'
Process finished with exit code 1
Cause analysis:
There are many error logs. When analyzing problems, we must learn to choose and read the log information that is useful for us to solve problems. From the error log I intercepted above, we can see that BeanInstantiationException and TypeException report two errors are reported. At the same time, there is an obvious error message for creating a certain entity class, such as Error creating bean with name 'mapperScannerConfigurer'.In fact, the most important error message is:: Could not resolve type alias 'PlatUserInfoResponse'. It can be determined that mybatis usage and return type error is reported. After troubleshooting, there is a problem with the return value path of PlatUserInfoResponse in the file, and the problem has been solved.
Solution:
When encountering such error messages, you can only find the direction from the following points:
1. The jar package conflict causes SpringBoot to repeatedly refer to different versions of a certain package, causing createBean to fail;
2. If a certain return entity does not exist, the path does not exist, resulting in an on-the-spot report a createBean failure error;
3. Cannot scan when scanning the package (if the database connection information is configured in the form of a configuration file when initializing the package scanning, such as Nacos configuration. Check whether the configuration file package path configuration is consistent with the package path in the code, and avoid repeated scanning)
4. The SpringBoot circular dependency problem can also be solved from this case.