我有一个配置参数“myconfig.defaultSize”,其值在application.properties文件中定义为例如“10MB”。如何预先处理来自spring配置文件的值?
另一方面,我有@ConfigurationProperties注解映射那些配置参数的@Component类,如下所示。
@Component
@ConfigurationProperties(prefix="myconfig")
public class StorageServiceProperties {
private Long defaultSize;
//...getters and setters
}
那么,我该如何应用一种方法将字符串值转换为Long?