Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You need to specify your using annotation configuration and component scan for the beans.</p> <pre><code>&lt;context:component-scan base-package="package.with.beans.**" /&gt; &lt;context:annotation-config/&gt; </code></pre> <p>Where <code>package.with.beans.**</code> is the package that contains the bean you are trying to inject the <code>LdapTemplate</code>. You can only inject beans into other beans, since they must be managed by the dependency injection container. So the class your trying to perform the injection in must be a bean and if that bean is established using an annotation, you must tell Spring to component scan to find that bean.</p> <p>For example: </p> <pre><code>package xx.yy.beans; //Used to annotate beans @Component public class Foo{ @Autowired private LdapTemplate ldapTemplate; } </code></pre> <p>Then after importing the <code>context</code> namespace for your <strong>Spring</strong> configuration would contain:</p> <pre><code>&lt;beans&gt; &lt;context:component-scan base-package="xx.yy.beans.**" /&gt; &lt;context:annotation-config/&gt; &lt;!-- LDAP Beans --&gt; &lt;bean id="contextSource" class="org.springframework.ldap.core.support.LdapContextSource"&gt; &lt;property name="url" value="ldap:***" /&gt; &lt;property name="base" value="dc=***,dc=***" /&gt; &lt;property name="userDn" value="uid=***,ou=***" /&gt; &lt;property name="password" value="***" /&gt; &lt;/bean&gt; &lt;bean id="ldapTemplate" class="org.springframework.ldap.core.LdapTemplate"&gt; &lt;constructor-arg ref="contextSource" /&gt; &lt;/bean&gt; &lt;bean id="personDao" class="com.example.dao.PersonDaoImpl"&gt; &lt;property name="ldapTemplate" ref="ldapTemplate" /&gt; &lt;/bean&gt; &lt;/beans&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload