The confusion of updating the content of the servlet's init() method after tomcat's hot loading is not calling

After the hot reload is turned on, the servlet will call the init() method for the first use. After the hot reload is turned on, the init() method is not executed after the updated servlet code. Furthermore, the construction method is not executed, which means that no object is created, but the service method is not executed. The modified code in can be updated automatically. Don't know the reason.

There is a guess, because the init and construction methods are not called after hot loading, then the servlet is still the original object, but the method area has been refreshed, then the constructed object will be refreshed if it still goes to the method area to find the method to run, and if it is The servlet class itself has a string, but it remains the same after the change (it does not change after testing). I guess it only refreshes the content of the method area, because no new object is created, so the string of the class attribute is still The content of the initial build. In fact, the init and destroy servlet can only be called once, and the hot reload is essentially in the refresh method area

Guess you like

Origin blog.csdn.net/qq_39655510/article/details/111301896