错误:nestedexceptionjava.lang.NoClassDefFoundError:org/springframework/data/auditing/config/AuditingHandlerBeanDefinitionParserjava.lang.ClassNotFoundException:org.springframework.data.auditing.config.AuditingHandlerBeanDefinitionParser诊断:该类AuditingHa..
分类:
编程语言 时间:
2014-08-06 06:18:31
阅读次数:
915
_id字段的映射:MongoDB要求所有的document都要有一个_id的字段。如果我们在使用中没有传入_id字段,它会自己创建一个ObjectId.{ "_id" : ObjectId("53e0ff0b0364cb4a98ce3bfd"), "_class" : "org.springfram...
分类:
数据库 时间:
2014-08-06 01:51:50
阅读次数:
416
MongoTemplate是数据库和代码之间的接口,对数据库的操作都在它里面。注:MongoTemplate是线程安全的。MongoTemplate实现了interfaceMongoOperations,一般推荐使用MongoOperations来进行相关的操作。MongoOperations mo...
分类:
数据库 时间:
2014-08-06 01:39:00
阅读次数:
273
1. 有了上一篇的Mongo后,连接数据库我们还需要更多的信息,比如数据库名字,用户名和密码等。我们可以继续来配置MongoDbFactory的实例。public interface MongoDbFactory { DB getDb() throws DataAccessException; .....
分类:
数据库 时间:
2014-08-06 01:21:20
阅读次数:
282
1. 通过Java based bean metadata@Configurationpublic class AppConfig {public @Bean Mongo mongo() throws UnknownHostExceptioin {return new Mongo("localhos...
分类:
数据库 时间:
2014-08-05 22:28:10
阅读次数:
172
有时,我们会需要用到自己定义的一些查询方法,可以按照下面几步进行。1. 定义一个包含该方法的接口Interface UserRepositoryCustom {public void someCustomMethod(User user);}2. 定义实现class UserRepositoryIm...
分类:
编程语言 时间:
2014-08-05 18:30:09
阅读次数:
228
如果想把一个方法加到所有的repository中,用前一篇提到的方法就不合适了。英文原版,请看http://docs.spring.io/spring-data/data-mongo/docs/1.5.2.RELEASE/reference/html/repositories.html#reposi...
分类:
编程语言 时间:
2014-08-05 18:28:19
阅读次数:
190
以下内容是在学习Spring-Data-mongoDB中的Spring Data Repositories时做的一些笔记。备忘!感觉学习还是看官方的资料比较透彻一些。Spring Data Repositories目的:减少重复的持久化代码。常用的几个repository interface,Rep...
分类:
编程语言 时间:
2014-08-05 18:08:49
阅读次数:
234
contextConfigLocation classpath:/spring-dataSource.xml, classpath:/spring-data.xml, classpath:/spring-server.xml, /WEB-INF/applicationCo...
分类:
Web程序 时间:
2014-08-02 01:49:02
阅读次数:
336
配置相关bean数据源 实体扫描并生成RepositoryMyName 自动更新数据库表结构(仅适用于开发阶段,正式运行后最好是手动维护数据库表结构) -->org.hibernate.cfg.ImprovedNamingStrategyupdatetruetrue事务,校验,测试时需要加事务注解@...
分类:
编程语言 时间:
2014-07-25 14:26:52
阅读次数:
403