Implementation of tomcat deployment project and integration with IDEA

Implementation of tomcat deployment project and integration with IDEA

3 ways to deploy projects with tomcat

  • Put the project directly into the webapps directory
  • Configure the conf/server.xml file
  • Create an xml file with any name in conf\catalina\localhost.

Put the project directly into the webapps directory

Create a new haha ​​folder, this folder is equivalent to a project

Create an a.xml file in the folder

The content of the xml file is

Copy the project to the webapps directory and restart tomcat

Visit Page

If garbled characters appear, you can refer to this solution to the Chinese garbled characters in Tomcat static pages (html)

/haha: Access path of the project --> virtual path

/a.html: resource path

Simplified method

Remove the haha ​​project first

Our tomcat is still running and has not been shut down.

Add one more file b.html to the project

Package a.html and b.html

Change the compressed file suffix to war package format

Put the war package into the webapps directory and find that the file is not automatically decompressed.

Check the log

From the log file, we can know that the required format is zip, rar format is not acceptable.

So we use 7Zip to compress it into zip format, and then change the format to war format

Then put c.war into the webapps directory and find that it is automatically decompressed

Because our tomcat is not closed, visit

Why? Because our virtual directory has changed, our war package is c.war, and the virtual directory after decompression is c, so revisit

Accessing b-files

When tomcat is running, if you delete the war package, the corresponding decompression folder will be automatically deleted, and the project will be deleted.

Disadvantage: Need to copy the project

Configure the conf/server.xml file (not recommended)

Now there is no customized project in my webapps directory

Create a heihei project in the folder of drive E. There is only a.html file in it, and the content of the file is in red words: Heihei Xia

Find the configuration file server.xml

Find the Host tag

Add the following configuration: <Context docBase="E:\heihei" path="/lala" />

Note:

docBase: the path of the project

path: virtual path

Start tomcat access

shortcoming:

Because the configuration is written in the server.xml file, the configuration in this file is the core configuration of Tomcat. If you configure and deploy it here, it may damage the configuration of Tomcat, and it will have to be restarted every time it is modified, so this method is not recommended.

Create an xml file with any name in conf\catalina\localhost. (Most recommended) (Hot deployment)

Create a hehe project in the folder of drive E. There is only a.html file in it, and the content of the file is in red words: hehexia

conf\catalina\localhost Create an XML file with any name

Add the following configuration to the xml file: <Context docBase="E:\hehe" />

Note: docBase: the path of the project

The virtual path accessed is the file name of this xml

Our tomcat is always started, no need to restart, directly access

This is hot deployment. In the future, when you add new projects, you can just add the XML file without restarting Tomcal.

If you don't need this project anymore, you don't need to delete it. Just change the file name suffix (you can choose any suffix)

After changing it, the project can no longer be accessed.

Integration of tomcat and IDEA

Integrated Configuration

idea

We are local now. Select the installation directory of Tomcat

In this way, Tomcat is integrated into idea

Creating a web project

Startup Success

Look at the log and see the path where our project is deployed to tomcat

access

The default setting is in the tomcat configuration file web.xml

We add another aa.html page to the new project

access

You need to restart the project and access it again

Hot deployment

We added an aa.html page above. We need to restart the project. Is it troublesome? Let's configure hot deployment.

Add another page bb.html

Direct access, no need to restart the project

This is the end of this article about tomcat deployment projects and the implementation of integration with IDEA. For more relevant tomcat deployment project content, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • How to deploy a Web project in Tomcat (must read)
  • Detailed explanation of the basic steps to deploy the Web project War package to the Tomcat server
  • Tomcat 7 deploys two projects by setting different ports
  • Detailed explanation of CentOS installation of tomcat and deployment of Java Web projects
  • Detailed steps for importing eclipse projects into IDEA and deploying them to tomcat
  • How to deploy JavaWeb project to Tomcat server in IDEA
  • Idea configures maven-tomcat-plugin to implement project deployment
  • Solve the problem that web project web page changes under tomcat deployment cannot be automatically refreshed
  • Detailed graphic explanation of the process of deploying the created Java web project to Tomcat in idea

<<:  How to handle token expiration in WeChat Mini Programs

>>:  Example code for implementing a QR code scanning box with CSS

Recommend

How to write object and param to play flash in firefox

Copy code The code is as follows: <object clas...

Analyzing the troublesome Aborted warning in MySQL through case studies

This article mainly introduces the relevant conte...

Causes and solutions for MySQL deadlock

The database, like the operating system, is a sha...

Vue-Element-Admin integrates its own interface to realize login jump

1. First look at the request configuration file, ...

Teach you how to use vscode to build a react-native development environment

question The code has no prompt: Many non-front-e...

Steps for docker container exit error code

Sometimes some docker containers exit after a per...

Detailed explanation of Javascript closures and applications

Table of contents Preface 1. What is a closure? 1...

Several ways to encapsulate breadcrumb function components in Vue3

Table of contents Preface 1. Why do we need bread...

Notes on configuring multiple proxies using vue projects

In the development process of Vue project, for th...

Disable autocomplete in html so it doesn't show history

The input box always displays the input history wh...

Analysis of the Principle and Method of Implementing Linux Disk Partition

remember: IDE disk: the first disk is hda, the se...