代码中读取配置文件中的东西

2020-12-03  本文已影响0人  自由主义者

1.application.yml配置:

query-balance-url: ${coin-application.host}/${coin.context-name}/api/account/balance
#生成路径
redirect-uri: https://hao123.com/semiconductor/saas-manager/invitation/getCode
getter-url: https://open.wx.qq.com/authorize?appid=${invitation.weixin-appid}&redirect_uri=${invitation.redirect-uri}&response_type=code&scope=${invitation.weixin-scope}&#wechat_redirect
#来源
tenant:
  source:
    map-value: {SEMICONDUCTOR_TENANT: '2c9480836d62f788016d630d5fbd0005'}

java代码:

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import java.util.Map;

@Configuration
@ConfigurationProperties(prefix = "tenant.source")
@Data
public class TenantSourceProperties {
    private Map<String,String> mapValue;
}

2.application.yml配置:

#路径
invitation:
  html-base-path: /usr/local/invitation

Java代码:

@Value("${invitation.html-base-path}")
private String basePath;
上一篇下一篇

猜你喜欢

热点阅读