首页 > 其他分享 >spring boot——读取应用配置——方式四——@PropertySource

spring boot——读取应用配置——方式四——@PropertySource

时间:2023-01-01 22:14:05浏览次数:38  
标签:PropertySource spring boot springframework annotation org import properties

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

=======================================================================

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

package org.example.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,spring,boot,springframework,annotation,org,import,properties
From: https://www.cnblogs.com/xiaobaibailongma/p/17018866.html

相关文章