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

相关推荐
易雪寒32 分钟前
IDEA在git提交时添加忽略文件
java·git·intellij-idea
爬山算法2 小时前
Maven(6)如何使用Maven进行项目构建?
java·maven
Zww08913 小时前
idea插件市场安装没反应
java·ide·intellij-idea
计算机学姐18 小时前
基于SpringBoot+Vue的在线投票系统
java·vue.js·spring boot·后端·学习·intellij-idea·mybatis
落落落sss18 小时前
MybatisPlus
android·java·开发语言·spring·tomcat·rabbitmq·mybatis
Jason不在家1 天前
Flink 本地 idea 调试开启 WebUI
大数据·flink·intellij-idea
菜鸟一皓1 天前
IDEA的lombok插件不生效了?!!
java·ide·intellij-idea
CS_GaoMing1 天前
Centos7 JDK 多版本管理与 Maven 构建问题和注意!
java·开发语言·maven·centos7·java多版本
Java探秘者2 天前
Maven下载、安装与环境配置详解:从零开始搭建高效Java开发环境
java·开发语言·数据库·spring boot·spring cloud·maven·idea
秋夫人2 天前
idea 同一个项目不同模块如何设置不同的jdk版本
java·开发语言·intellij-idea