spring boot使用环境加载yml来映射

时间:2018-06-13 07:16:33

标签: java spring spring-boot yaml

我的yml如下:

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
    RateChartTableViewCell *cell1 = (RateChartTableViewCell *)cell;

    if(indexPath.section == 0 && indexPath.row == 4)
    {
        [tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
        UIBezierPath *maskPath = [UIBezierPath 
    bezierPathWithRoundedRect:cell1.containerView.bounds byRoundingCorners:( UIRectCornerBottomLeft | UIRectCornerBottomRight) cornerRadii:CGSizeMake(10.0, 10.0)];
        CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
        maskLayer.frame = tableView.bounds;
        maskLayer.path  = maskPath.CGPath;
        cell1.containerView.layer.mask = maskLayer;
        cell1.containerView.clipsToBounds = YES;
    }
}

application: address: '0xb7716e1f5690a841d698dd64ae13727bf719b2cd': '4' '0x0f020200ad0729f19be98ddb26685d80359428b7': '5' 环境变量如下 -

Autowired

现在@Autowired Environment environment; 的环境会返回getProperty

null

如何将地址作为地图类型?

1 个答案:

答案 0 :(得分:0)

@ConfigurationProperties("application")

并将变量设置为revice private Map<String,String> address;

并添加get和set方法

public Map<String, String> getAddress() { return address; }

public void setAddress(Map<String, String> address) { this.address = address; }

你明白了