其他分享
首页 > 其他分享> > 使用@PropertySource和@Value读取其它自定义的参数文件里面的参数值

使用@PropertySource和@Value读取其它自定义的参数文件里面的参数值

作者:互联网

package com.tszr.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@PropertySource({"test.properties", "ok.properties"})
public class PropertySourceValueReaderOhterController {
    @Value("${my.msg}")
    private String mymsg;
    @Value("${your.msg}")
    private String yourmsg;

    @RequestMapping("/testProperty")
    public String testProperty() {
        return "其他配置文件test.properties:" + mymsg + "<br>" + "其他配置文件ok.properties:" + yourmsg;
    }
}

 

标签:PropertySource,自定义,springframework,annotation,Value,org,import,properties
来源: https://www.cnblogs.com/tszr/p/15965884.html