博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Maven_profile_使用profile配置不同环境的properties(实践)
阅读量:7289 次
发布时间:2019-06-30

本文共 1348 字,大约阅读时间需要 4 分钟。

配置方法分为以下几个步骤:
1、配置profiles节点(pom.xml)
2、配置build节点(pom.xml)--
如果不配置该节点则无法找到profile中的properties属性值,并且配置后超链接才有效
3、使用(在xml或properties中使用)

4、执行maven命令,使profiles的local节点生效

1、配置profiles节点(pom.xml)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<
profiles
>
       
<
profile
>
           
<
activation
>
              
<!-- <os>
                   
<family>Windows</family>
               
</os>-->
               
<
activeByDefault
>true</
activeByDefault
>
           
</
activation
>
           
<
id
>local</
id
>
           
<
properties
>
               
<
dubbo.registry.address
>10.6.1.1:2181</
dubbo.registry.address
>
               
<
jdbc.passwod
></
jdbc.passwod
>
           
</
properties
>
       
</
profile
>
       
<
profile
>
           
<
id
>test</
id
>
           
<
properties
>
               
<
dubbo.registry.address
>10.6.14.11:2181</
dubbo.registry.address
>
           
</
properties
>
       
</
profile
>
   
</
profiles
>

2、配置build节点(pom.xml)

1
2
3
4
5
6
7
8
9
10
11
12
13
<
build
>
       
<
resources
>
           
<
resource
>
               
<
directory
>${project.basedir}/src/main/resources</
directory
>
               
<
filtering
>true</
filtering
>
           
</
resource
>
           
<
resource
>
               
<
directory
>${project.basedir}/bin</
directory
>
               
<
targetPath
>/bin</
targetPath
>
               
<
filtering
>true</
filtering
>
           
</
resource
>
       
</
resources
>
   
</
build
>

3、使用(在xml或properties中使用)

a) xml文件中使用

  <dubbo:registry protocol="zookeeper" address="${dubbo.registry.address}"/>

b) properties文件中使用

jdbc.password=${jdbc.passwod}

4、执行maven命令,使profiles的local节点生效

install -P local -DskipTests

转载于:https://www.cnblogs.com/gossip/p/6072601.html

你可能感兴趣的文章
C#系列-多样化的程序分支[7]
查看>>
Keepalived配置文件详解(以Haproxy作为负载均衡器)
查看>>
megacli创建RAID10过程详解
查看>>
Linux系统引导过程
查看>>
【apache】mod_proxy 和 mod_rewrite实现js跨域
查看>>
林锐博士谈考研
查看>>
Vant Weapp小程序蹲坑之使用checkbox组件
查看>>
重载operator<<运算符时第二个参数最好不要写成指向对象的指针
查看>>
在ubuntu上编译 wpa_supplicant-2.6
查看>>
68ES6_解构_数组操作_对象操作
查看>>
poj——1470 Closest Common Ancestors
查看>>
Mysql Master/Slave Set Up
查看>>
自动化部署Newton版OpenStack (一)
查看>>
我的友情链接
查看>>
几个经典的Spring学习资料
查看>>
Objective-C 常用代码
查看>>
linux下IPTABLES配置详解
查看>>
由网络引起的打印故障和邮件问题
查看>>
xml相关
查看>>
如何将App从一个账号迁移到另一个账号?
查看>>