Detailed tutorial on running Tomcat in debug mode in IDEA Maven project

Detailed tutorial on running Tomcat in debug mode in IDEA Maven project

1. Add the following dependencies in pom.xml

<dependency>
 <groupId>javax.servlet</groupId>
 <artifactId>javax.servlet-api</artifactId>
 <version>3.0.1</version>
 <scope>provided</scope> // This is the scope</dependency>
<dependency>
 <groupId>javax.servlet.jsp</groupId>
 <artifactId>jsp-api</artifactId>
 <version>2.2</version>
 <scope>provided</scope> // This is the scope</dependency>

Note: It needs to be placed in <dependencies></dependencies> , otherwise an error will be reported

I use mvn tomcat:run, which will lead to a problem: although I configure tomcat7, tomcat6 is used by default, and tomcat6 does not support jdk1.8. Here you need to add the tomcat7-maven-plugin plug-in. Note: If your version is tomcat7-maven-plugin 2.0, since it does not support jdk 1.8, just replace it with tomcat7-maven-plugin 2.2. Add the following code in pom.xml:

<plugin>
 <groupId>org.apache.tomcat.maven</groupId>
 <artifactId>tomcat7-maven-plugin</artifactId>
 <version>2.2</version>
</plugin>

That's it.

"IDEA maven cannot import static files such as css, js, img, etc."
Add in web.xml (add whatever files need to be intercepted)

<servlet-mapping>
 <servlet-name>default</servlet-name>
 <url-pattern>*.js</url-pattern>
 <url-pattern>*.css</url-pattern>
 <url-pattern>*.map</url-pattern>
 <url-pattern>*.jpg</url-pattern>
 <url-pattern>*.png</url-pattern>
 <url-pattern>*.eot</url-pattern>
 <url-pattern>*.svg</url-pattern>
 <url-pattern>*.ttf</url-pattern>
 <url-pattern>*.woff</url-pattern>
 <url-pattern>*.otf</url-pattern>
 <url-pattern>*.woff2</url-pattern>
 <url-pattern>*.gif</url-pattern>
</servlet-mapping>

Add to the jsp page:

<%
 String path = request.getContextPath();
 String basePath = request.getScheme() + "://"
   + request.getServerName() + ":" + request.getServerPort()
   + path + "/";
%>

Then you can directly reference bathPath, such as:

<link rel="stylesheet" href="<%=basePath%>/css/bootstrap.min.css" rel="external nofollow" type="text/css">

Tomcat created by Maven, running in debug mode

1. First enter the edit structure.

insert image description here

2. Select the green "+" sign and scroll down to find the "Maven" option and click it.

insert image description here

3. Select the project to be debugged.

insert image description here

4. Just run the debug program.

insert image description here

5. Copy this path + file directory and you can access it

insert image description here

Modify the front-end code of the Maven project, click somewhere else, and refresh the webpage without restarting Maven.

Note:

This deployment is only useful for jsp page modification, not for Servlet, and also cannot recognize html

This is the end of this article about the detailed tutorial on how to use debug mode to run Tomcat in IDEA Maven project. For more information about how to use debug mode to run Tomcat in IDEA Maven project, 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:
  • The IDEA process has ended, exit code -1073741819 (0xC0000005) bug
  • Detailed explanation of IntelliJ IDEA 2020's Debug function
  • Detailed explanation of the reasons and solutions for IDEA starting tomcat port occupation (using debug mode)
  • Intellij idea remote debug connects tomcat to achieve single-step debugging
  • IDEA uses SpotBugs to find bugs in your code

<<:  Native js to achieve simple carousel effect

>>:  MySQL 8.0.20 installation tutorial and detailed tutorial on installation issues

Recommend

Summary of 10 must-see JavaScript interview questions (recommended)

1.This points to 1. Who calls whom? example: func...

Example code for implementing the wavy water ball effect using CSS

Today I learned a new CSS special effect, the wav...

Vue3 encapsulates its own paging component

This article example shares the specific code of ...

Solve the problem of MySQL Threads_running surge and slow query

Table of contents background Problem Description ...

Introduction to JavaScript strict mode use strict

Table of contents 1. Overview 1.1 What is strict ...

Installation process of zabbix-agent on Kylin V10

1. Download the installation package Download add...

JavaScript code to implement a simple calculator

This article example shares the specific code of ...

VMware vSphere 6.7 (ESXI 6.7) graphic installation steps

Environment: VMware VCSA 6.7 (VMware-VCSA-all-6.7...

Nginx configures the same domain name to support both http and https access

Nginx is configured with the same domain name, wh...

Implementing long shadow of text in less in CSS3

This article mainly introduces how to implement l...

Specific use of MySQL internal temporary tables

Table of contents UNION Table initialization Exec...

innodb_flush_method value method (example explanation)

Several typical values ​​of innodb_flush_method f...

How to Change Colors and Themes in Vim on Linux

Vim is a text editor that we use very often in Li...