xyhjyh 2014-07-29 13:28
浏览 209
已采纳

有用过spring-mongodb的没?

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

  • 写回答

2条回答 默认 最新

  • leehuat 2014-07-29 13:40
    关注

    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]

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?