In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article shares a sample analysis of tomcat-related configurations integrated with eclipse. Xiaobian thinks it is quite practical, so share it with everyone for reference. Let's follow Xiaobian and have a look.
tomcat related configuration integrated with eclipse
Tomcat is a popular open source and free Web application server. First of all, Tomcat is closely related to Java, so install JDK and set JDK environment variables before installing and using it. Since JDK has been installed on the machine and JDK environment variables have been set, I won't describe it too much here. I only explain the environment variables I set:
JAVA_HOME:F:\JDK_Kit
CLASSPATH:.;% JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;(with a dot at the front)
Add: ;%JAVA_HOME%\bin; at the beginning of the path (with a semicolon)
Enter java-version in the cmd window to see if the environment variables are set successfully:
My JDK version is 1.8.0_45.
Okay, so you have the JDK environment variables configured. Let's get started with Tomcat.
First Baidu search Tomcat, to Apache's official website download, here is the latest version of Tomcat8 selected
After clicking in, the selection is zip format, that is, the installment-free version, because my machine is 64-bit Windows, so choose the following:
After downloading, extract it to my custom TomCat_8.0.24 folder under drive F:
Once you're done, you'll need to configure Tomcat's environment variables and some settings:
Create a new TOMCAT_HOME in the environment variable, and the value is the directory where Tomcat is located, that is, F:\TomCat_8.0.24
In addition, CATALINA_HOME and CATALINA_BASE are newly created, where CATALINA_HOME is the Tomcat installation directory, CATALINA_BASE is the Tomcat working directory,
I don't know yet, so I'll set it to %TOMCAT_HOME%
After configuring Tomcat environment variables, we need to configure some files in Tomcat:
Open the bin folder under the Tomcat installation directory, we want to supplement startup.bat and shutdown.bat,
Edit these two files by adding the following two lines to the first line of the file, before @echooff:
SETJAVA_HOME=JDK Directory
SETCATALINA_HOME= directory of unzipped Tomcat
For my system, this is configured to:
SETJAVA_HOME=F:\JDK_Kit
SETCATALINA_HOME=F:\TomCat_8.0.24
After completing this step, you can click startup.bat to start the server and click shutdown.bat to shut down the server. Of course, this is only one of the ways.
Several ways to start and shut down Tomcat are described later.
Tomcat should be added to the service next
The zip version downloaded from the Internet requires Tomcat to be added to the service, otherwise Tomcat cannot be configured, and tomcat8w.exe in the bin folder cannot be opened.
As you can see from the Task Manager, click the star button on the tomcat8w.exe program to launch tomcat8.exe.
To add tomcat to the service, navigate to the directory where the bin folder is located in cmd and type service.batinstall
You will then see a list of environment variables that you have just configured and a prompt that Tomcat has been installed:
Note: Each line here should clearly show the value of each environment variable setting. If any parameter has no value, only double quotes are displayed, which is an error.
In this case, although tomcat8w.exe can be opened, clicking the start button will not start the service (that is, it cannot switch to the state where the stop button can be pressed).
You can also type cmd services.msc to call up the service to see if there is Apache Tomcat 8(default is manual start, if changed to automatic start, then boot Tomcat will start in the background)
So far, the basic configuration is complete, and there may be some minor configurations, such as setting Tomcat user names and passwords, which will be covered later.
Tomcat Startup
After configuring Tomcat, we care whether these configurations are successful, so we need to start Tomcat to verify that Tomcat has several startup methods:
The first one: (not recommended)
This method can only be enabled on your own computer (suitable for your own computer to test web applications), other people's computers are unable to connect to your own computer's tomcat server, after many verifications.
Start in cmd of the command console and type the following in cmd to turn on or off the Tomcat server:
netstart service name
netstop service name
Tomcat service names are Tomcat+ version numbers, such as Tomcat6, Tomcat7. Since my version of Tomcat is Tomcat8, the service name here is Tomcat8
This way, the startup display in Task Manager is:
The latter two methods are additionally displayed as:
Therefore, the abnormality of this method is also reflected from the side door, so it is not recommended! Not recommended! Not recommended!
The second is to use the startup.bat batch file to turn on the Tomcat server and the shutdown.bat batch file to turn off the Tomcat server. For this method, as mentioned earlier, you should add
SETJAVA_HOME=JDK directory and SETCATALINA_HOME= decompressed Tomcat directory
The third type: enter the bin folder of the Tomcat directory, open the Tomcat7w.exe program, select the star key in the open window to open the server, and select the stop key to close the server.
Verification of Tomcat
Knowing the various ways to open Tomcat, we can verify whether Tomcat can work. Choose any way to start Tomcat, such as typing netstartTomcat8 in cmd.
Prompt Tomcat server started successfully, open the browser, enter localhost:8080
If Tomcat works, open Tomcat Web site, verify Tomcat is working:
When the test is over, don't forget to turn off the server. Turn it off as you choose:
Finally, a few small things:
1. Tomcat can set user name and password. In the conf directory of Tomcat directory, there is a tomcat-users.xml file. Click it to edit user name and password.
Add a line above/tomcat-users in the last line:
userusername="admin"password="123456"roles="manager-gui"/
You can set your username and password to admin and 123456
There is also a small knowledge point here, the role determines whether you are tomcat administrator, if you are an administrator, you can manage tomcat, such as deploying web references.
2. The default port number of Tomcat is 8080. You can open server.xml under the conf directory in the Tomcat directory and find this line:
You can see that the port number is 8080, which can be changed to any port number.
The above is Tomcat from download to configuration, and finally start and verify all the process, if you want to use Eclipse with Tomcat to develop, you also need to configure Tomcat in Eclipse
Start Eclipse first, click Window, select the last item Preferences, open the Preferences window, click Server, select the last item RuntimeEnviroments,
At this time, click the [Add] button in the window to add the server:
Select a Tomcat server to configure:
Set up the directory where Tomcat is located and the JRE used:
This completes the Eclipse and Tomcat association, but the Tomcat server has not yet been created.
To create a Tomcat server, click on the Servers tab on the toolbar below Eclipse where the console is located, and the following prompt will appear:
Then we click according to the prompt, and the following window will pop up:
Eclipse automatically helped us select the [Tomcat v8.0 Server] option. Since we don't have resources yet, we can click [Finish] directly to see the [Servers] tag at this time:
After the Tomcat server is created, you need to configure the Tomcat server. Double-click the server created under the Servers tab to pop up the Overview window of the server. Find the ServerLocations configuration option and select the UseTomcat installation option. In this way, the Serverpath below will be automatically set to the Tomcat server installation directory, and then manually set the Deploypath to webapps, thus completing all the configurations of the Tomcat server in Eclipse:
We can click on the green button, this button is to start the server, we will see that the server status under the [Servers] tab has changed to start, and there is also an end button activated:
At the same time click on the [Console] tab, we can also see some information:
Description Tomcat has been successfully launched in Eclipse, then open the browser and enter localhost:8080:
At this point you can see that the Tomcat server is indeed working:
This indicates that Tomcat has been configured successfully in Eclipse and is working properly.
PostScript
Some of the problems that arise:
After double-clicking the server to open the Overview window, you can see that some ports can be set in the right part of the interface, including Tomcat port, HTTP port and AJP port.
1. Sometimes it will prompt (8005,8080,8009) port is occupied, it may be because other software to occupy one of these three ports (this is the most likely reason, it is likely Javaw this process to occupy),
Then just force it to close.
Thank you for reading! About "tomcat related configuration and eclipse integration example analysis" This article is shared here, I hope the above content can have some help for everyone, so that everyone can learn more knowledge, if you think the article is good, you can share it to let more people see it!
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.