[The way to get into the pit in Java] The project in Spring Boot compiles normally, but the RestController interface suddenly cannot be accessed


foreword

I'm working on a project recently, using spring boot development, I can still access the local interface this morning, I updated the interface in the afternoon, and then suddenly I can't access it at night, but everything is normal during the compilation process (the picture below is the compiled log) , and finally after my step-by-step testing (stepping on the pit), I finally solved the problem, and recorded my thinking process through this article.
insert image description here


ideas

Is the network normal

If the interface cannot be accessed, it may be a network problem. I tried to reconnect to the network (PS: The school's network is often disconnected, and it is suspected that it is a network problem). After confirming that I can access the Internet normally, I can access the interface again, but it still doesn't work.

insert image description here

Remove newly added code

Since there is no problem with the network and can be accessed normally in the morning, could it be caused by the code added in the afternoon? With this doubt, I pointed the finger at the code added in the afternoon, deleted all the code added in the afternoon , and again Compilation is normal, but it is not accessible.

Remove code that may have exceptions

After deleting the code in the afternoon, the problem still could not be solved. I changed another way of thinking and deleted the interface that was very likely to have problems . For example, there may be some potentially abnormal interfaces, but the problem still could not be solved after deletion.

Rollback to the previous normal version via git

This is embarrassing, but fortunately, save the git local warehouse in the morning, and after a wave of git operations, roll back to the previous normal version

git log --oneline #用一行的形式打印出git的日志
git reset --hard 索引值 #通过reset回滚到指定索引值的版本

insert image description here
I thought the last normal version was definitely accessible, but it turned out! ! Or not! No, this is not as expected, there must be something wrong!

Check if the certificate has expired

Since I accessed through HTTPS, I guessed whether the certificate expired . I checked Alibaba Cloud's SSL certificate management console. No, it's still several months before it expires! ! !

restart IDEA

Is there something wrong with IDEA? ? ? I restart IDEA to compile normally, but still cannot access the interface! ! !

Use IDEA to create a new test case

Guessing whether it is just my project that has a problem, I use IDEA to create a simple test case , and the result is that the test case is accessible!

The ultimate nirvana - restart the computer

This is strange. I suddenly thought of the last solution. Restart the computer . Restarting may solve 80 to 90% of the problems.

Hahaha, that's ok, it's very comfortable to see this.
insert image description here


Summarize

This is the process I encountered and solved today. Although there is no technical content, I hope to provide a solution to the problem for the friends who are reading this article.
In the process of developing the project, it is recommended that you develop the habit of version management. You can use git to help you save the code of each update to the local warehouse. If you encounter a bug that cannot be solved for a while, you can try to roll back to the previous normal version . Make a backup of the latest code and develop a good habit.

===================================================== =======================
The above is the dividing line, updated at 15:32 on May 15, 2019

follow-up

After a few days, I found that I still couldn't use postman to request https! Is there a small partner who can't follow the above method like me? It doesn't matter, just click the link below, and a solution has been found for you!
What's wrong with postman requesting the https interface?

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326076217&siteId=291194637