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. C#中const 详细分析与说明

    const是一个c语言的关键字,它限定一个变量不允许被改变.使用const在一定程度上可以提高程序的安全性和可靠性,另外,在观看别人代码的时候,清晰理解const所起的作用,对理解对方的程序也有一些帮 ...

  2. netty服务端实现心跳超时的主动拆链

    一.服务器启动示例: public class MySocketServer { protected static Logger logger = LoggerFactory.getLogger(My ...

  3. 转: 使用Hystrix实现自动降级与依赖隔离

    使用Hystrix实现自动降级与依赖隔离 原创 2017年06月25日 17:28:01 标签: 异步 / 降级 869 这篇文章是记录了自己的一次集成Hystrix的经验,原本写在公司内部wiki里 ...

  4. 图数据库titan 和 rexster安装手册

    titan是图数据库, rexster是图显示服务 titan 安装 下载 titan 0.3.2 解压 titan-all-0.3.2.zip 到 /opt/hugedata/share/解压后得到 ...

  5. ansible 学习记录

    Ansible 的重新学习记录 这里我的Ansible的宿主机是centos 7.2系统,这里我通过yum 安装Ansible 1.配置epel源 sudo yum -y install epel-r ...

  6. navicat cannot create oci 解决

    1.新建连接 2.连接时候报错 3.解决 3.1.选择对应版本OCI 3.1.配置OCI[工具->选项...]

  7. 微服务,ApiGateway 与 Kong

    一. 微服务 二. Api Gateway 三. Kong 的使用 一. 微服务 对于一些传统的 大型项目,传统的方式会有一些缺陷,比如说 新人熟悉系统成本高(因为整个系统作为一个整体,彼此会有一定的 ...

  8. Java:多线程,CountDownLatch同步器

    1. 背景 CountDownLatch类,在完成一组正在其他线程中执行的操作之前,它允许一个或多个线程一直等待. 用给定的计数 初始化 CountDownLatch.由于调用了 countDown( ...

  9. javascript <a> 标签打开相对路径,绝对路径

    <a>标签中的href中,如果你写一个路径默认是以相对路径打开的,加上"http://" 消息头那就可以打开绝对路径 html: <a href=javascri ...

  10. 【Unity】10.1 类人动画的导入和设置

    分类:Unity.C#.VS2015 创建日期:2016-05-02 一.制作或购买类人模型 为了充分使用 Mecanim 类人动画系统和类人动画的动画重定位功能,需要先使用其他3D建模软件(例如3d ...