是否可以使用Spring @Value将属性文件中的值映射到HashMap.
目前我有类似的东西,映射一个值不是问题.但我需要在HashMap过期中映射自定义值.这样的事情可能吗?
@Service
@PropertySource(value = "classpath:my_service.properties")
public class SomeServiceImpl implements SomeService {
@Value("#{conf['service.cache']}")
private final boolean useCache = false;
@Value("#{conf['service.expiration.[<custom name>]']}")
private final HashMap<String, String> expirations = new HashMap<String, String>();
Run Code Online (Sandbox Code Playgroud)
属性文件:'my_service.properties'
service.cache=true
service.expiration.name1=100
service.expiration.name2=20
Run Code Online (Sandbox Code Playgroud)
像这个键映射是否可行:值集
name1 = 100
name2 = 20
我正在使用Gradle Spring 依赖项管理器插件在项目中导入Maven BOM定义。我需要排除BOM中定义的一个模块。
做这样的事情会很好,但是mavenBom只接受字符串。
dependencyManagement {
imports {
mavenBom ('io.spring.platform:platform-bom:1.0.1.RELEASE') {
exclude 'com.datastax.cassandra:cassandra-driver-dse'
}
}
}
Run Code Online (Sandbox Code Playgroud)
是否可以通过其他方式排除BOM中定义的特定模块?