IDEA基础——Maven配置tomcat

配置方案

  • [一、配置maven-tomcat plugin插件(只最高支持到tomcat 8)](#一、配置maven-tomcat plugin插件(只最高支持到tomcat 8))
    • [~~1.添加镜像源,获取tomcat 8插件配置~~](#1.添加镜像源,获取tomcat 8插件配置)
      • [~~1.1 在pom.xml里先添加镜像源~~](#1.1 在pom.xml里先添加镜像源)
      • [~~1.2 添加tomcat插件配置~~](#1.2 添加tomcat插件配置)
    • [2. 添加tomact官方发布的插件配置(无需添加镜像源,直接获取)](#2. 添加tomact官方发布的插件配置(无需添加镜像源,直接获取))
  • 二、idea本地配置tomcat运行
    • [1. 配置tomcat关联当前项目模块](#1. 配置tomcat关联当前项目模块)
      • [1.1 创建tomcat服务器配置](#1.1 创建tomcat服务器配置)
      • [1.2 选择部署当前项目模块为热部署exploded](#1.2 选择部署当前项目模块为热部署exploded)

一、配置maven-tomcat plugin插件(只最高支持到tomcat 8)

1.添加镜像源,获取tomcat 8插件配置

tomcat官方最后发型的version2.2版本是2013年,因此最高只能兼容tomcat7

镜像源网址:https://artifacts.alfresco.com/nexus/content/groups/public

tomcat-plugin路径:org/apache/tomcat/maven/tomcat8-maven-plugin

tomcat支持版本:3.0-r1655215;3.0-r1756463
目前测试此版本tomcat表现的问题颇多,如果想使用tomcat8以上版本呢建议使用第二种方法,也就是标题的第二种方法。

此方法只能成功运行,甚至都没法加载maven自带的web模板,直接500报错,不想折腾直接配置本地完事

1.1 在pom.xml里先添加镜像源

xml 复制代码
<!-- 导入Maven plugin镜像源 -->
    <pluginRepositories>
        <pluginRepository>
            <id>alfresco-public</id>
            <url>https://artifacts.alfresco.com/nexus/content/groups/public</url>
        </pluginRepository>
    </pluginRepositories>

1.2 添加tomcat插件配置

xml 复制代码
	<plugin>
		<groupId>org.apache.tomcat.maven</groupId>
		<artifactId>tomcat8-maven-plugin</artifactId>
		<version>3.0-r1756463</version>
		<configuration>
		<port>8080</port>
		<!-- 项目发布到 tomcat 后的名称,如果为/则默认直接访问localhost:8080/ -->
		<path>/</path>
		<uriEncoding>utf-8</uriEncoding>
		</configuration>
	</plugin>

2. 添加tomact官方发布的插件配置(无需添加镜像源,直接获取)

xml 复制代码
	<plugin>
	    <groupId>org.apache.tomcat.maven</groupId>
	    <artifactId>tomcat7-maven-plugin</artifactId>
	    <version>2.2</version>
	    <configuration>
	        <!-- 设置编码格式 -->
	        <uriEncoding>UTF-8</uriEncoding>
	        <!-- 控制 tomcat 端口号 -->
	        <port>8080</port>
	        <!-- 项目发布到 tomcat 后的名称 -->
	        <!-- 如果写 /abc,相当于项目发布后的名称为 abc -->
	        <path>/</path>
	    </configuration>
	</plugin>

二、idea本地配置tomcat运行

1. 配置tomcat关联当前项目模块

1.1 创建tomcat服务器配置




1.2 选择部署当前项目模块为热部署exploded

热部署是在项目重启的时候会自动将更新后的可执行文件加载进tomcat运行应用中,而并不需要重启tomcat应用,但idea中依然需要重新运行项目



这里额外说明一下,如果启动tomcat想修改项目在url里的访问路径可以通过如下方式修改

如果项目部署里没有exploded项目请执行如下操作

相关推荐
sugar__salt1 天前
Spring 三层架构与 IoC、依赖注入完全指南
java·spring boot·后端·spring·架构·maven·intellij-idea
还是鼠鼠1 天前
【Spring AI智能体实战 02】Spring Boot 3.4整合Spring AI:项目创建与依赖配置
java·人工智能·spring boot·maven·spring ai
cyadyx1 天前
Nexus管理私服
maven·nexus
mh_f2 天前
34.JRebel启动报错问题
intellij-idea
程序员钟霖2 天前
【实战版】Spring IOC 控制反转详解
java·后端·spring·maven·intellij-idea
骇客野人2 天前
IntelliJ IDEA 菜单中英对照
java·ide·intellij-idea
骇客野人3 天前
IDEA 安装 Trae(TRAE AI: Coding Assistant)完整步骤
java·ide·intellij-idea
骇客野人3 天前
IntelliJ IDEA 使用技巧
java·ide·intellij-idea
我命由我123453 天前
Java 开发 - List subList 方法
java·windows·操作系统·list·intellij-idea·idea·intellij idea
减瓦3 天前
Maven 源码包的下载与工程化落地
java·maven