java配置文件优先级_spring 读取配置文件的优先级

spring 读取配置文件的优先级1 结论在spring加载properties配置文件的过程中,会根据key出现覆盖现象,后加载的覆盖前面的。加载顺序keyvalue最终输出p1testConver没有覆盖,为p1覆盖,为p2属性p1test测试区测试区p2testConver覆盖,为p2属性覆盖,为p2属性p2test开发区开发区2 上干活2.1 java 代码单元测试类为:import or...
摘要由CSDN通过智能技术生成

spring 读取配置文件的优先级

1 结论

在spring加载properties配置文件的过程中,会根据key出现覆盖现象,后加载的覆盖前面的。

加载顺序

key

value

最终输出

p1

testConver

没有覆盖,为p1

覆盖,为p2属性

p1

test

测试区

测试区

p2

testConver

覆盖,为p2属性

覆盖,为p2属性

p2

test

开发区

开发区

2 上干活

2.1 java 代码

单元测试类为:

import org.junit.Test;

import org.junit.runner.RunWith;

import org.springframework.beans.factory.annotation.Value;

import org.springframework.test.context.ContextConfiguration;

import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

@RunWith(SpringJUnit4ClassRunner.class)

@ContextConfiguration(value = "classpath:/spring-resources.xml")

public class SpringPropertie

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值