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项目请执行如下操作

相关推荐
m0_743697598 小时前
CentOS Stream 9 综合实验:FTP、DNS 与 Tomcat 排障
centos·tomcat·firefox
开开心心_Every20 小时前
快速隐藏程序工具自定义快捷键一键切换
java·开发语言·前端·spring·智能手机·word·intellij-idea
CarIise1 天前
Spring 框架:多配置文件、开发方式与 IOC 注解
junit·maven·jar
博风1 天前
eclipse中配置maven,以及在本地使用maven。
java·eclipse·maven
golang学习记2 天前
IDEA 断点调试技巧:拖拽
java·ide·intellij-idea
少年的范儿2 天前
IntelliJ IDEA 配置 JDK 21 与 Maven 教程(Windows):开发环境配置与验证
java·jdk·maven·intellij idea
guocy-ww3 天前
JetBrains 全家桶(IDEA、PyCharm等)合法免费方案 审核中
pycharm·intellij-idea
行者-全栈开发3 天前
【码动四季·秋】把 Spring Boot 的 Tomcat 换成 Undertow:一次容器替换的三处暗坑
spring boot·tomcat·容器化·依赖管理·undertow
peach4 天前
同样是装依赖,为什么 npm 长成 node_modules,Maven 长成 .m2
npm·node.js·maven
weixin_399380694 天前
TongWeb7.0.4.9M11如何接入到idea(by lqw)
java·ide·intellij-idea