如何实现xml命名空间throgh spring annotation

时间:2015-05-21 12:09:28

标签: java spring

我正在尝试实施spring-data-mongo,我正在通过@configuration@bean(而不是xml文件)定义我的bean。

现在我需要包含以下命名空间才能获得mongoTemplate

xmlns:mongo="http://www.springframework.org/schema/data/mongo" 

在我的bean配置中。

我仍然可以使用xml配置并在我的应用程序上下文中加载它,但我只是想知道命名空间是否可以通过spring注释实现。

1 个答案:

答案 0 :(得分:1)

将@EnableMongoRepositories添加到您的配置类。

来源:http://docs.spring.io/spring-data/data-mongo/docs/1.7.0.RELEASE/reference/html/#mongo.repositories