java:Tomcat

background

Before talking about what Tomcat is, let's understand some concepts.

server

It can be understood as a high-performance computer, but this computer does not have any software installed.
insert image description here

web server

Install some server software on this server, such as nginx, Apache, Tomcat, etc. This server can help us receive user requests, process requests, and respond.

Tomcat is a web server software, common java-related web server software:

  • webLogic: oracle company, a large-scale JavaEE server, supports all JavaEE specifications, and charges.
  • webSphere: IBM Corporation, a large-scale JavaEE server, supports all JavaEE specifications, and charges.
  • JBOSS: JBOSS company, a large-scale JavaEE server, supports all JavaEE specifications, charges.
  • Tomcat: Apache Foundation, a small and medium-sized JavaEE server, only supports a small number of JavaEE standard servlets/jsp. Open source and free.

Classification of service resources

  1. Static resources: After all users visit, the results are the same, called static resources. Static resources can be directly parsed by the browser
    • Such as: html, css, JavaScript
  2. Dynamic resources: After each user accesses the same resource, the results obtained may be different. called dynamic resources. After the dynamic resource is accessed, it needs to be converted into a static resource first, and then returned to the browser
    • Such as: servlet/jsp, php, asp...

Classification of server software

1. Web server: all server software can be called web server software
2. HTTP server (static service): use HTTP protocol to transmit resources and provide services
3. Application server (dynamic service): a container for a specific application

Web server: As the name suggests, the function of the Web is to provide Web-based services. So what is called Web service? To understand it simply, for example: website page service, mail service, network download service, etc., can all be called Web services.
All in all, in a broad sense, a web server is to respond to user needs and provide responses and services. So from this perspective, almost all server software can be called a Web server.

nginx and tomact

Nginx: A typical static server, which can be used as a reverse proxy and load balancing. It is generally placed at the front to face users directly, and cooperates with Tomcat on the back end to play the front line; written in pure C, it has high performance, very little memory consumption, and considerable stability Well, Internet companies heavily use

Tomcat: Produced by Apache, a typical application server software, an application container that conforms to the Servlet standard, and can also provide http services, but generally not as an http server; it is the default built-in server of the Spring Boot framework

Summarize

Tomcat can resolve dynamic resources (of course, static resources can also be resolved, but not the main) java project.

Install Tomcat

brew install

brew install tomcat

The installation directory is/opt/homebrew/opt/tomcat@8

vi ~/.bash_profile
export PATH=$PATH:/opt/homebrew/opt/tomcat@8/bin
source ~/.bash_profile
# 查看Tomcat基本信息
catalina -h
catalina run

insert image description here
If you want to deploy Servlets, the root directory of the project will generally have this folder, see here for details
insert image description here

Official website compression package installation

http://tomcat.apache.org
insert image description here

tar -zxvf tomcat压缩包路径 ~/Library/tomcat
# 为了方便把文件夹名称改为tomcat,或者建立一个软连接
# 软连接
ln -s ~/Library/apache-tomcat-8.5.54 ~/Library/tomcat
# 修改文件夹名称
mv ~/Library/apache-tomcat-8.5.54 ~/Library/tomcat

Add environment variables

vim .bash_profile
export TOMCAT_HOME=/Users/用户名/Library/tomcat
export PATH=$PATH:$TOMCAT_HOME/bin
source .bash_profile

Authorize the permissions under the bin directory

cd ~/Library/tomcat/bin
sudo chmod 755 *.sh

startup and shutdown

startup.sh
shutdown.sh

IDEA integration

insert image description here

insert image description here
Put the path you installed with brew here
insert image description here
/opt/homebrew/Cellar/tomcat@8/8.5.76/libexec
insert image description here
Add our project here
insert image description here

IDEA plugin

pom.xml

<build>
    <!--maven插件-->
    <plugins>
        <!--tomcat插件-->
        <plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <!-- tomcat7的插件, 不同tomcat版本这个也不一样 -->
            <artifactId>tomcat7-maven-plugin</artifactId>
            <version>2.1</version>
            <configuration>
                <!-- 通过maven tomcat7:run运行项目时,访问项目的端口号 -->
                <port>80</port>
                <!-- 项目访问路径  本例:localhost:9090,  如果配置的aa, 则访问路径为localhost:9090/aa-->
                <path>/travel</path>
            </configuration>
        </plugin>

    </plugins>
</build>

insert image description here

illustrate

insert image description here

Guess you like

Origin blog.csdn.net/weixin_43972437/article/details/132474432