【问题标题】:Spring-ldap via annotations instead of XMLSpring-ldap 通过注解而不是 XML
【发布时间】:2015-09-16 05:56:09
【问题描述】:

我已经从 SO 问题 Best practice for configuring Spring LdapTemplate via annotations instead of XML? 中得到了设置 LdapContextSource 和 LdapTemplate 的答案,而无需 XML 配置

下面xml的注解方式应该是什么——基于接口自动创建repository beans?

<ldap:repositories base-package="org.springframework.ldap.samples.useradmin.domain" />

【问题讨论】:

    标签: annotations spring-boot spring-ldap


    【解决方案1】:

    类似的东西。

    @Configuration
    @EnableLdapRepositories("org.springframework.ldap.samples.useradmin.domain")
    public class LdapConfiguration { ... }
    

    @EnableLdapRepositories 负责添加正确的配置并扫描存储库。

    【讨论】:

    • 并且应该添加依赖&lt;dependency&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-starter-data-jpa&lt;/artifactId&gt; &lt;/dependency&gt;来使用CrudRepository
    • 不,它不应该...这是针对 JPA 而不是针对 LDAP...您应该只添加 spring-data-commons 依赖项。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-10-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-18
    相关资源
    最近更新 更多