【发布时间】:2016-02-09 17:29:18
【问题描述】:
Spring Data KeyValue 看起来非常适合快速启动模拟微服务。如何使用数据引导它?
我尝试向KeyValueAdapter 添加东西,但通过自己指定 bean,我最终得到了 Repositorys,它与 不同 KeyValueAdapter 连接,等等没有可用的数据。
@Configuration
@EnableMapRepositories
public class PersistenceConfig
{
@Bean
public KeyValueAdapter keyValueAdapter() {
KeyValueAdapter adapter = new MapKeyValueAdapter(ConcurrentHashMap.class);
Account testAccount = new Account();
testAccount.id = "dj-asc-test";
testAccount.givenName = "Gertrude";
adapter.put(testAccount.id, testAccount, "accounts");
Account read = (Account) adapter.get("dj-asc-test", "accounts");
Assert.notNull(read);
return adapter;
}
}
【问题讨论】:
标签: java spring-data spring-data-keyvalue