Project scenario ：
SpringBoot When the project starts Console Console log printing stuck , No abnormal information is printed
Problem description ：
The previous project was good , But after I wrote part of the code , The project won't start ,SpringBoot When the project starts, it gets stuck , Logs don't print either , There is no specific information about the exception , One of my colleagues had a day .
Cause analysis ：
I've had similar problems before . Now I list all my problem analysis below ：
- Maybe it's a change pom.xml file , The project has not been completely updated , Leading to the introduction of jar There is a version problem or it is not introduced at all
- The project is Debug mode , Then there are some special breakpoints that cause the project to start stuck
- Project directory structure changes , Lead to some bean Not loaded into ？ Or loaded multiple identical bean
- Some exceptions are not caught , At the same time, there is no global try-catch, Cause the project to jam
- Part of the code needs to be booted with the program , Use @PostConstruct、InitializingBean、ApplicationRunner To realize the loading of project initialization , If there is a remote connection , And the connection failed or abnormal , No, try-catch, It is also easy to cause the startup program to get stuck .
For the analysis listed above , We can use the following solutions , Try it step by step
- If it is pom.xml The change didn't take effect , We just need to be right pom.xml again import that will do , In addition, consider removing idea cache
- If it is debug If it's caused by a breakpoint in the pattern , Remove all breakpoints and try again
- If it's a project directory structure change , This maven clean once , again install that will do
- If you can change the startup class , It is recommended that the main The code in the method is added with try-catch, In this way, you can know what the specific exception is when you start the project
- If we analyze which program self starting code causes the project startup to get stuck , I suggest checking the project startup snapshot , As follows ：
Analyze what the current main thread is stuck with (waiting), For example, I am stuck due to the configuration problem of the data source
Final solution ：6、 If none of the above problems can be solved , Then you can view the project startup log file , It's usually at the same level as the project or there's a log Directory storage , All the information will be recorded in it / Abnormal information
for example ： Here's my colleague's exception ：
Abnormal analysis ： It's because he came from another project copy Over here mapper.xml file , It used to be mybatis, Now the project uses ibatis, Don't recognize <where> label ,ibatis Only support <dynamic prepend="where"> To use
Change to ibatis The way of identification is . Here we focus on how to find and analyze anomalies .
Project start stuck , There must be an abnormal reason , What we need is composure , Step by step, find the problem . The other thing is that people are CV Code , Especially when it comes to two different projects , Pay attention to the details ！
Participation of this paper Tencent cloud media sharing plan , You are welcome to join us , share .
本文为[The blank of writing memory]所创，转载请带上原文链接，感谢