CAS (13) —— CAS 使用Maven Profile支持多环境编译

摘要

CAS 使用Maven Profile支持多环境编译


版本

tomcat版本: tomcat-8.0.29

jdk版本: jdk1.8.0_65

cas版本: 4.1.3

**cas4.1.3 (4.x还在开发过程中不是很稳定,迭代比较快,也会有些bug) **

cas-client-3.4.1

maven版本: 3.3.9

主要内容

准备

以项目github上CAS项目为例进行扩充

  • 参考文章

CAS (1) —— Mac下配置CAS到Tomcat(服务端)

配置

扩充不同环境下需要定制配置文件目录

Profile使用

<profiles>
<profile>
<id>local8433</id>
<properties>
<env>local8433</env>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>*.bak</exclude>
</excludes>
</resource>
<resource>
<directory>src/main/resources-config/local8433</directory>
</resource>
</resources>
</build>
</profile>
<profile>
<id>local8443</id>
<properties>
<env>local8443</env>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>*.bak</exclude>
</excludes>
</resource>
<resource>
<directory>src/main/resources-config/local8443</directory>
</resource>
</resources>
</build>
</profile> <profile>
<id>local</id>
<properties>
<env>local</env>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>*.bak</exclude>
</excludes>
</resource>
<resource>
<directory>src/main/resources-config/local</directory>
</resource>
</resources>
</build>
</profile>
<profile>
<id>dev</id>
<properties>
<env>dev</env>
</properties>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>*.bak</exclude>
</excludes>
</resource>
<resource>
<directory>src/main/resources-config/dev</directory>
</resource>
</resources>
</build>
</profile>
<profile>
<id>qa</id>
<properties>
<env>qa</env>
</properties>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>*.bak</exclude>
</excludes>
</resource>
<resource>
<directory>src/main/resources-config/qa</directory>
</resource>
</resources>
</build>
</profile>
<profile>
<id>prod</id>
<properties>
<env>prod</env>
</properties>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>*.bak</exclude>
</excludes>
</resource>
<resource>
<directory>src/main/resources-config/prod</directory>
</resource>
</resources>
</build>
</profile>
<profile>
<id>prod215</id>
<properties>
<env>prod215</env>
</properties>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>*.bak</exclude>
</excludes>
</resource>
<resource>
<directory>src/main/resources-config/prod215</directory>
</resource>
</resources>
</build>
</profile>
<profile>
<id>prod216</id>
<properties>
<env>prod216</env>
</properties>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>*.bak</exclude>
</excludes>
</resource>
<resource>
<directory>src/main/resources-config/prod216</directory>
</resource>
</resources>
</build>
</profile>
</profiles>

Filter使用

<build>
<filters>
<filter>${basedir}/src/main/webapp-config/${env}/filters/cas.properties</filter>
<!--<filter>${basedir}/src/main/webapp-config/${env}/filters/spring-configuration/ticketRegistryDataSource.xml</filter>-->
<!--<filter>${basedir}/src/main/webapp-config/${env}/filters/spring-configuration/authenticationDataSource.xml</filter>-->
<filter>${basedir}/src/main/webapp-config/${env}/filters/spring-configuration/authenticationEncoder.xml</filter>
</filters> <plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<warName>cas</warName>
<webResources>
<resource>
<directory>${basedir}/src/main/webapp/WEB-INF</directory>
<filtering>true</filtering>
<targetPath>WEB-INF</targetPath>
<includes>
<include>**/web.xml</include>
</includes>
<excludes>
<exclude>**.bak</exclude>
</excludes>
</resource>
<resource>
<directory>${basedir}/src/main/webapp-config/${env}/filters</directory>
<filtering>true</filtering>
<targetPath>WEB-INF</targetPath>
<includes>
<include>*.properties</include>
<include>**.xml</include>
</includes>
</resource>
<resource>
<directory>${basedir}/src/main/webapp-config/${env}/filters/spring-configuration</directory>
<filtering>true</filtering>
<targetPath>WEB-INF/spring-configuration</targetPath>
<includes>
<include>*.properties</include>
<include>**.xml</include>
</includes>
</resource>
</webResources>
</configuration>
</plugin>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${maven-jetty-plugin.version}</version>
<configuration>
<webApp>
<contextPath>/cas</contextPath>
</webApp>
</configuration>
</plugin>
</build>

参考

Introduction to Build Profiles

CAS (7) —— Mac下配置CAS 4.x集群及JPATicketRegistry

结束

CAS (13) —— CAS 使用Maven Profile支持多环境编译的更多相关文章

  1. 使用maven profile实现多环境可移植构建(转自CSDN)

    使用maven profile实现多环境可移植构建 标签: maven profilemaven自动构建maven自动部署maven可移植构建持续集成 2014-04-25 23:37 26905人阅 ...

  2. 使用Maven Profile实现多环境构建

    在开发过程中,我们的软件会面对不同的运行环境,比如开发环境.测试环境.生产环境,而我们的软件在不同的环境中,有的配置可能会不一样,比如数据源配置.日志文件配置.以及一些软件运行过程中的基本配置,那每次 ...

  3. 使用maven profile实现多环境可移植构建

    mvn clean package -Pproduction即构建出生产环境需要的war包 mvn tomcat:redeploy -Ptest 即发布到测试环境 在开发过程中,我们的软件会面对不同的 ...

  4. maven profile实现多环境打包

    快速解决: 项目目录 1.pom文件中添加profile <profiles> <profile> <!-- 本地开发环境 --> <id>dev< ...

  5. 通过maven profile 打包指定环境配置

    背景 最近换了个新公司接手了一个老项目,然后比较坑的是这个公司的项目都没有没有做多环境打包配置,每次发布一个环境都要手动的去修改配置文件.今天正好有空就来配置下. 解决这个问题的方式有很多,我这里挑选 ...

  6. maven profile实现多环境配置

    每次项目部署上线都需要手动去修改配置文件(比如数据库配置,或者一个自定义的配置)然后才能打包,很麻烦,网上找到 maven profile可以完成这个工作,记录如下: 环境:eclipse + spr ...

  7. Maven profile 打包分环境加载不同的资源文件

    在实际开发项目中,常常有几种环境,一般情况下最少有三种环境:开发.测试.正式. 各个环境之间的参数各不相同,比如mysql.等不同环境的host不一样,若每个环境都手动替换环境很容易出错,这里我们利用 ...

  8. 【转】maven profile实现多环境打包

    作为一名程序员,在开发的过程中,经常需要面对不同的运行环境(开发环境.测试环境.生产环境.内网环境.外网环境等等),在不同的环境中,相关的配置一般不一样,比如数据源配置.日志文件配置.以及一些软件运行 ...

  9. maven profile切换正式环境和测试环境

    有时候,我们在开发和部署的时候,有很多配置文件数据是不一样的,比如连接mysql,连接redis,一些properties文件等等 每次部署或者开发都要改配置文件太麻烦了,这个时候,就需要用到mave ...

随机推荐

  1. 坑爹的高德地图API

    症状 ld: '-[MASearch poiSearchWithOption:]' in *****/Release-iphonesimulator/libMASearchKit.a(MASearch ...

  2. 配置IISserver

    我们自己开发站点的时候   要在自己的电脑上写网页 然后我们怎么能像我们浏览互联网上的网页一样.而不是直接双击打开网页呢   这时候就要配置IISserver  让自己能够 预览自己站点的效果 以下是 ...

  3. python 爬虫 重复下载 二次请求

    在写爬虫的时候,难免会遇到报错,比如 4XX ,5XX,有些可能是网络的原因,或者一些其他的原因,这个时候我们希望程序去做第二次下载, 有一种很low的解决方案,比如是用  try  except t ...

  4. linux进程后台运行,且关终端后继续运行

    ctrl+z,fg,bg什么的都无法实现这一点.因为关终端之后就可能出问题 常用的命令如下 nohup /home/user/yourcommand.sh & nohup /home/user ...

  5. SQL Server 自增字段归零

    方法一: 如果曾经的数据都不需要的话,可以直接清空所有数据,并将自增字段恢复从1开始计数 truncate table 表名 方法二: DBCC CHECKIDENT (''table_name'', ...

  6. 开源企业IM-免费企业即时通讯-ENTBOOST V2014.180 Windows版本号正式公布

    ENTBOOST,VERSION 2014.180 Linux版本号公布,主要添加企业IM应用集成功能,完好安卓SDK功能及部分BUG修正. 下一版本号公布时间.7月15日.敬请关注. ENTBOOS ...

  7. 【Unity】5.1 3D坐标系基础知识

    分类:Unity.C#.VS2015 创建日期:2016-04-20 一.简介 在虚拟的游戏世界中,与3D有关的数学知识决定了游戏引擎如何计算和模拟出开发者以及玩家看到的每一帧画面.学习或者回想一下基 ...

  8. 菜鸟调错(六)——Hibernate 4.3.x 注解常见错误及解决方案

    编程的过程免不了遇到各种错误,各种问题,而遇到问题,解决问题的这个过程我认为是最让人兴奋的事情.越棘手的问题,解决以后带来的快感也越大.当一个问题你搞了一下午或者一天,甚至几天,当你解决的那一刻你会觉 ...

  9. 菜鸟学EJB(一)——第一个实例

    EJB用了那么长时间了,从来没写过关于它的东西,挺对不住它的.今天先写一个简单的小实例,虽然小但是却能体现出EJB的核心——分布式.我们可以将业务逻辑的接口跟实现部署到一台机器上,将调用它们的客户端部 ...

  10. 解决myeclipse/eclipse创建或导入maven工程时引发的问题

    起因: 最近学习maven,按照教程把命令行创建的maven工程导入到eclipse/myeclipse,由于库中没有一些依赖包,所以在导入工程的时候开发工具自动下载依赖包.可是,由于天朝特殊环境的问 ...