You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -94,34 +121,10 @@ Right now, this interface serves only typing purposes, but we can add additional
94
121
----
95
122
====
96
123
97
-
This namespace element causes the base packages to be scanned for interfaces that extend `LdapRepository` and create Spring beans for each one found. By default the repositories get an autowired `LdapTemplate` Spring bean that is called `ldapTemplate`, so you only need to configure `ldap-template-ref` explicitly if you deviate from this convention.
98
-
99
-
If you want to go with Java configuration, use the `@EnableLdapRepositories` annotation. The annotation carries the same attributes as the namespace element. If no base package is configured, the infrastructure scans the package of the annotated configuration class. The following example shows how to set up Java configuration:
124
+
This configuration causes the base packages to be scanned for interfaces that extend `LdapRepository` and create Spring beans for each one found.
125
+
By default, the repositories get an autowired `LdapTemplate` Spring bean that is called `ldapTemplate`, so you only need to configure `ldap-template-ref` explicitly if you deviate from this convention.
100
126
101
-
.Java configuration for repositories
102
-
====
103
-
[source,java]
104
-
----
105
-
@Configuration
106
-
@EnableLdapRepositories
107
-
class ApplicationConfig {
108
-
109
-
@Bean
110
-
ContextSource contextSource() {
111
-
112
-
LdapContextSource ldapContextSource = new LdapContextSource();
If you want to go with Java configuration, use the `@EnableLdapRepositories` annotation. The annotation carries the same attributes as the namespace element. If no base package is configured, the infrastructure scans the package of the annotated configuration class.
125
128
126
129
Because our domain repository extends `CrudRepository`, it provides you with CRUD operations as well as methods for access to the entities. Working with the repository instance is a matter of dependency injecting it into a client.
127
130
@@ -131,14 +134,14 @@ We can add paging access to our repository, as follows:
131
134
====
132
135
[source,java]
133
136
----
134
-
@RunWith(SpringJUnit4ClassRunner.class)
137
+
@ExtendWith({SpringExtension.class})
135
138
@ContextConfiguration
136
-
public class PersonRepositoryTests {
139
+
class PersonRepositoryTests {
137
140
138
141
@Autowired PersonRepository repository;
139
142
140
143
@Test
141
-
public void readAll() {
144
+
void readAll() {
142
145
143
146
List<Person> persons = repository.findAll();
144
147
assertThat(persons.isEmpty(), is(false));
@@ -158,7 +161,7 @@ Most of the data access operations you usually trigger on a repository result in
158
161
====
159
162
[source,java]
160
163
----
161
-
public interface PersonRepository extends PagingAndSortingRepository<Person, String> {
0 commit comments