有用过spring-mongodb的没?

有用过spring-mongodb的没?跟传统mongodb啥区别啊,有啥优势劣势

spring data 结合mongodb的
依赖的包mongo-java-driver

[code="xml"]
<?xml version="1.0" encoding="UTF-8"?>
xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
context:annotation-config/



/context:component-scan








[/code]

[code="java"]
@Repository
public class PersonRepository {

static final Logger logger = LoggerFactory.getLogger(PersonRepository.class);
@Autowired
MongoTemplate mongoTemplate;

public void logAllPersons() {
List results = mongoTemplate.findAll(Person.class);

}
}
[/code]

spring-mongodb 是spring为了方便整合集成 mongodb 的插件,就跟很多我们常见的spring-jms ,spring-jmx等等是一样的。提供了很多模版,就像jdbc一样,他也有spring-jdbc,是在基础上面的封装。楼上的例子mongoTemplate 就是一个模板,封装了很多mongodb的api。方便代码开发。 核心的lib还是依赖于你所说的传统的 mongodb包。