In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the knowledge of "how to start a web project through tomcat source code". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Learning background
In the last wave, we learned the methods and relationships of the main interfaces in tomcat:
Https://www.lixiang.red/articles/2019/08/12/1565622240937.html
In fact, the source code can only be seen by looking at it. If you keep looking at it later, it is easy to get confused. There is a saying that true knowledge comes from practice.
Today, let's start our daily web application through the tomcat source code. In the middle, we can debug, and we can see the whole process better.
Prepare the web application
You can quickly generate a web application in https://start.spring.io/
Then build the project and get the following directory structure:
We open it with ide, add a controller, and pack it into a war package for backup.
Then drop the war package into the webapp directory of tomcat
The configuration of tomcat is imported into the jar package into idea
For ant-related configurations, please refer to this article
Https://www.lixiang.red/articles/2019/08/04/1564907616303.html
After executing the deploy command, we can see the dropped jar package in the tomcat-build-libs directory
Then import these packages into idea
Open the project settings panel first
Click the button to add jar package
Find the corresponding tomcat-build-libs directory, select all the following files, including the ant.jar we downloaded, and finally click OK
Modify some configurations of tomcat itself
Delete the tomcat/webapps/examples directory, which is full of examples, which will report errors in the compilation of the source code and interfere with our normal startup. You can delete them first.
Modify the port number of tomcat (optional) in tomcat/conf/server.xml, just as we usually deploy the application
Start tomcat and trace
As we have talked before, when you start tomcat with a shell script, you start the Bootstrap.java class and follow the parameter start.
So, we need to add start to the startup parameters of idea
Breakpoint: you can start tracking the breakpoint at the entry entry we mentioned earlier, that is, the main function.
Let go of the breakpoint and continue to run for a while, you can see the interface started by spring
Finally, we visit the controller we wrote in the browser, and we can see the corresponding return.
This is the end of the content of "how to start a web project through tomcat source code". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.