maven—profiles区分环境的配置文件
来源:互联网 发布:php {{asset}} 编辑:程序博客网 时间:2024/05/16 11:10
在我们的开发过程中一般会有 本地--测试--预发布--生产 几个环境,相对应的数据库连接配置等的一些配置信息都是不一样的,
profiles 节点下可以配置多个profile 节点 每个节点都有id ,activeByDefault 为true 表示使用这个profile配置,也可以在我们 mvn package -P test 打包的时候通过 -P参数来指定,最后在代码中我们就可以使用properties中定义的配置文件了,这里使用@value注解来读取属性文件
使用maven 的profiles 可以很方便的来区分这些配置文件
在项目的pom文件中定义
<profiles> <profile> <id>test</id> <activation> <activeByDefault>true</activeByDefault> </activation> <properties> <mvn.spring.version>4.1</mvn.spring.version> <mvn.basedir>${project.basedir}</mvn.basedir> </properties> </profile> <profile> <id>product</id> <activation> <activeByDefault>true</activeByDefault> </activation> <properties> <mvn.spring.version>1.1</mvn.spring.version> <mvn.basedir>D:test/</mvn.basedir> </properties> </profile> </profiles> <build> <resources> <resource> <directory>src/main/resources</directory> <includes> <include>**/*.properties</include> </includes> <filtering>true</filtering> </resource> </resources> </build>
build 节点表示替换的配置文件的位置
profiles 节点下可以配置多个profile 节点 每个节点都有id ,activeByDefault 为true 表示使用这个profile配置,也可以在我们 mvn package -P test 打包的时候通过 -P参数来指定,最后在代码中我们就可以使用properties中定义的配置文件了,这里使用@value注解来读取属性文件
阅读全文
0 0
- maven—profiles区分环境的配置文件
- Maven profiles构建开发、集测、生产环境配置文件
- maven的profiles节点
- Maven <Profiles>定义不同环境的参数变量
- Maven的pom.xml文件结构之环境配置profiles
- Maven <Profiles>定义不同环境的参数变量
- Maven <Profiles>定义不同环境的参数变量
- 关于maven中profiles多环境的配置
- maven+eslipse 多环境打包 profiles
- maven profiles
- maven profiles
- maven profiles
- maven profiles
- maven profiles
- Maven Profiles
- Using Maven profiles and resource filtering(针对不同环境启用不同的配置值)
- 【maven】5、Maven 多环境部署(filters、resources、profiles)
- maven多环境多配置文件的解决方案
- /*学习笔记*/《c++语言程序程序设计(第4版)》郑莉 清华大学出版社
- Skiing
- PHP 常量的定义及如何设置
- c++整型与二进制的相互转化
- TCL嵌入式测试技术在Comware V7系统中的应用
- maven—profiles区分环境的配置文件
- mysql中的数据类型enum和set
- Android Service(服务)详解·(一)相关知识点引入
- CC2640R2F BLE5.0 开发工具集
- NVIDIA DIGITS 5.1-dev学习笔记之安装过程记录:Windows10 x64位系统 、 MicroSoft Caffe Master、CUDA 8.0 、Python 2.7
- HDU 5984 ACM-ICPC Regional QingDao(数学期望)
- c/c++编程小知识1
- vue2中(路由/父子/组件/事件)数据通信方法总结
- POJ 3630 Phone List