1.

<context:property-placeholder location="classpath:conf/*.properties" file-encoding="UTF-8"/>

 

2.:

@Component
@PropertySource(value = "classpath:conf/copyWriteUI.properties",encoding = "utf-8")
@Getter
public class CopyWriteUI {
    @Value("${a}")
    private String a;
    @Value("${b}")
    private String b;
    }

  

3.

附录 spring <context:property-placeholder/> 的属性说明

<context:property-placeholder   
        location="属性文件,多个之间逗号分隔"  
        file-encoding="文件编码"  
        ignore-resource-not-found="是否忽略找不到的属性文件"  
        ignore-unresolvable="是否忽略解析不到的属性,如果不忽略,找不到将抛出异常"  
        properties-ref="本地Properties配置"  
        local-override="是否本地覆盖模式,即如果true,那么properties-ref的属性将覆盖location加载的属性,否则相反"  
        system-properties-mode="系统属性模式,默认ENVIRONMENT(表示先找ENVIRONMENT,再找properties-ref/location的),NEVER:表示永远不用ENVIRONMENT的,OVERRIDE类似于ENVIRONMENT"  
        order="顺序"  
        /> 

  

相关文章:

  • 2022-12-29
  • 2022-01-21
  • 2021-07-04
  • 2022-01-25
  • 2022-12-23
  • 2021-08-24
  • 2021-09-09
  • 2021-09-02
猜你喜欢
  • 2021-08-25
  • 2021-09-07
  • 2022-12-23
  • 2022-01-19
  • 2021-08-16
  • 2021-09-16
  • 2021-06-29
相关资源
相似解决方案