为什么需要
现在同时维护着dev、test、demo、uat环境,由于现在没有绑定域名,在做单点登录的时候,每次打包都需要手动修改web.xml中的ip地址,十分麻烦,并且非常容易出错。
怎么做
使用maven的profile
1.在pom的profile中添加如下代码:新增cas.serverLoginUrl、cas.serverName、cas.serverUrlPrefix三个properties
<profiles> <profile>
<id>development</id>
<activation>
<activeByDefault> true </activeByDefault>
</activation>
<properties>
<profiles.active>dev</profiles.active>
<mybatis.log>ERROR</mybatis.log>
<log.path>/home/lirui/dev</log.path>
<cas.serverLoginUrl>http: //10.11.100.48:8880/login</cas.serverLoginUrl>
<cas.serverName>http: //10.11.11.167:8080</cas.serverName>
<cas.serverUrlPrefix>http: //10.11.100.48:8880/</cas.serverUrlPrefix>
</properties>
</profile>
<profile>
<id>test</id>
<properties>
<profiles.active>test</profiles.active>
<mybatis.log>ERROR</mybatis.log>
<cas.serverLoginUrl>http: //10.11.100.48:8880/login</cas.serverLoginUrl>
<cas.serverName>http: //localhost:8080</cas.serverName>
<cas.serverUrlPrefix>http: //10.11.100.48:8880/</cas.serverUrlPrefix>
</properties>
</profile>
<profile>
<id>demo</id>
<properties>
<profiles.active>demo</profiles.active>
<mybatis.log>ERROR</mybatis.log>
<cas.serverLoginUrl>http: //123.57.27.212</cas.serverLoginUrl>
<cas.serverName>http: //123.56.120.217</cas.serverName>
<cas.serverUrlPrefix>http: //123.57.27.212</cas.serverUrlPrefix>
</properties>
</profile>
<profile>
<id>uat</id>
<properties>
<profiles.active>uat</profiles.active>
<mybatis.log>ERROR</mybatis.log>
<cas.serverLoginUrl>http: //123.57.237.183</cas.serverLoginUrl>
<cas.serverName>http: //123.57.85.22</cas.serverName>
<cas.serverUrlPrefix>http: //123.57.237.183</cas.serverUrlPrefix>
</properties>
</profile>
<profile>
<id>pre</id>
<properties>
<profiles.active>pre</profiles.active>
<mybatis.log>ERROR</mybatis.log>
</properties>
</profile>
<profile>
<id>production</id>
<properties>
<profiles.active>pro</profiles.active>
<mybatis.log>ERROR</mybatis.log>
</properties>
</profile>
</profiles> |
2.在web module的pom中,新增过滤web资源配置
<plugin> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version> 2.1 . 1 </version>
<configuration>
<webResources>
<resource>
<directory>src/main/webapp</directory>
<filtering> true </filtering>
</resource>
</webResources>
</configuration>
</plugin> |
3.在web.xml中用占位符替换
<filter> <filter-name>CASFilter</filter-name>
<filter- class >com.ezubo.global.om.web.filter.LoginFilter</filter- class >
<init-param>
<param-name>casServerLoginUrl</param-name>
<param-value>${cas.serverLoginUrl}</param-value>
</init-param>
<init-param>
<param-name>serverName</param-name>
<param-value>${cas.serverName}</param-value>
</init-param>
<init-param>
<param-name>noFilterUrl</param-name>
<param-value>*.js</param-value>
</init-param>
</filter> |
4.打包时加入-P,如demo环境 mvn clean package -DskipTests -Pdemo
5.没了
相关推荐
一、Idea关联的maven本地仓库配置文件settings.xml (1)必须使用默认文件名 D:\developsoft\javaweb\commonPlugins\maven\apache-maven-3.8.1_first\conf\settings.xml 二、Myeclipse关联的maven本地仓库配置文件...
主要介绍了Maven pom.xml与settings.xml详解的相关资料,这里对pom.xml与setting.xml详细的研究说明,需要的朋友可以参考下
用于maven setting.xml文件丢失,eclipse集成maven插件.m2下无setting.xml文件需要配置的情况
由于经常使用Maven创建web工程所以需要使用web.xml默认模板
国内连接maven官方的仓库更新依赖,收集一些国内快速的maven仓库镜像以备用。 settings.xml配置好的国内私服,直接可以下载使用!
settings.xml配置
2021-10-28官网下载archetype-catalog.xml。(maven项目快速搭建,缺少这个文件时,提示maven-archetype-webapp could not resolve archetpye)
创建Java Web工程,没有Web.xml文件会报异常,本文档提供了解决该异常的方法。
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=...
Maven原版settings.xml配置文件,根据个人需要,可以打开对应注释或替换相关阿里云镜像或远程仓库地址即可使用。
linux 环境下安装maven 拉去资源jar settings.xml 配置文件
maven的set.xml配置文件
本文主要阐述了maven build是用来干什么的,以及对build标签中各子元素配置的作用
maven完整国内镜像配置文件,包含12个仓库资源。
记录一下自己常用的maven工程的pom.xml配置详解,各个标签详解
maven linux 安装时配置文件 settings.xml 配置阿里云镜像 使用时请修改本地仓库路径
maven的settings.xml配置,提供maven包下载位置,刚刚maven仓库镜像仓库下载。 <localRepository>D:/develop/apache-maven-3.6.0/repository <id>alimaven <name>aliyun maven <url>...
分享一个快的飞起的maven的settings.xml文件. 直接使用开源中国的中央仓库。
<groupId>org.apache.maven.plugins <artifactId>maven-shade-plugin <version>3.1.0 <phase>package <goal>shade implementation="org.apache.maven.plugins.shade.resource....
settings.xml maven