Skip to content

Commit 218d836

Browse files
committed
Consolidated configuration classes.
Moved all of the into src/main/java. Got rid off the common superclass as it now adds more noise than clarity.
1 parent 955d5d9 commit 218d836

File tree

9 files changed

+48
-95
lines changed

9 files changed

+48
-95
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright 2014 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springframework.data.jpa.example.repository.auditing;
17+
18+
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
19+
import org.springframework.context.annotation.Bean;
20+
import org.springframework.context.annotation.Configuration;
21+
import org.springframework.data.jpa.example.InfrastructureConfig;
22+
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
23+
24+
/**
25+
* @author Oliver Gierke
26+
*/
27+
@Configuration
28+
@EnableAutoConfiguration
29+
@EnableJpaAuditing
30+
class AuditingConfiguration extends InfrastructureConfig {
31+
32+
@Bean
33+
AuditorAwareImpl auditorAware() {
34+
return new AuditorAwareImpl();
35+
}
36+
}

spring-data-jpa-example/src/main/java/org/springframework/data/jpa/example/repository/caching/CachingConfiguration.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2013 the original author or authors.
2+
* Copyright 2013-2014 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -17,15 +17,14 @@
1717

1818
import java.util.Arrays;
1919

20+
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
2021
import org.springframework.cache.Cache;
2122
import org.springframework.cache.CacheManager;
2223
import org.springframework.cache.annotation.EnableCaching;
2324
import org.springframework.cache.concurrent.ConcurrentMapCache;
2425
import org.springframework.cache.support.SimpleCacheManager;
2526
import org.springframework.context.annotation.Bean;
2627
import org.springframework.context.annotation.Configuration;
27-
import org.springframework.context.annotation.ImportResource;
28-
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
2928

3029
/**
3130
* Java config to use Spring Data JPA alongside the Spring caching support.
@@ -34,10 +33,9 @@
3433
* @author Thomas Darimont
3534
*/
3635
@Configuration
37-
@EnableJpaRepositories
38-
@ImportResource("classpath:infrastructure.xml")
3936
@EnableCaching
40-
public class CachingConfiguration {
37+
@EnableAutoConfiguration
38+
class CachingConfiguration {
4139

4240
@Bean
4341
public CacheManager cacheManager() {
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Sample for the integration of the Spring Caching abstraction with Spring Data repositories.
2+
* Sample for the integration of the Spring caching abstraction with Spring Data repositories.
33
*/
44
package org.springframework.data.jpa.example.repository.caching;
55

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2013 the original author or authors.
2+
* Copyright 2013-2014 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -15,11 +15,8 @@
1515
*/
1616
package org.springframework.data.jpa.example.repository.custom;
1717

18-
import org.springframework.context.annotation.ComponentScan;
18+
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
1919
import org.springframework.context.annotation.Configuration;
20-
import org.springframework.context.annotation.Import;
21-
import org.springframework.data.jpa.example.repository.InfrastructureConfig;
22-
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
2320

2421
/**
2522
* Sample configuration to bootstrap Spring Data JPA through JavaConfig
@@ -28,7 +25,5 @@
2825
* @author Oliver Gierke
2926
*/
3027
@Configuration
31-
@ComponentScan
32-
@Import(InfrastructureConfig.class)
33-
@EnableJpaRepositories
28+
@EnableAutoConfiguration
3429
public class CustomRepositoryConfig {}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Package showing a repository interface to use basic finder method execution functionality as well as <em>customized</em> repository functionality.
2+
* Package showing a repository interface to use basic query method execution functionality as well as <em>customized</em> repository functionality.
33
*/
44
package org.springframework.data.jpa.example.repository.custom;
55

Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Package showing a simple repository interface to use basic finder method execution functionality.
2+
* Package showing a simple repository interface to use basic query method execution functionality.
33
*/
44
package org.springframework.data.jpa.example.repository.simple;
55

spring-data-jpa-example/src/test/java/org/springframework/data/jpa/example/repository/InfrastructureConfig.java

Lines changed: 0 additions & 61 deletions
This file was deleted.

spring-data-jpa-example/src/test/java/org/springframework/data/jpa/example/repository/auditing/JavaConfigAuditableUserSample.java

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,14 @@
1515
*/
1616
package org.springframework.data.jpa.example.repository.auditing;
1717

18-
import org.springframework.context.annotation.Bean;
19-
import org.springframework.context.annotation.Configuration;
20-
import org.springframework.data.jpa.example.repository.InfrastructureConfig;
21-
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
22-
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
2318
import org.springframework.test.context.ContextConfiguration;
2419

2520
/**
2621
* Test case to show Spring Data JPA auditing with JavaConfig
2722
*
2823
* @author Oliver Gierke
2924
*/
30-
@ContextConfiguration
25+
@ContextConfiguration(classes = AuditingConfiguration.class)
3126
public class JavaConfigAuditableUserSample extends AbstractAuditableUserSample {
3227

33-
@Configuration
34-
@EnableJpaRepositories
35-
@EnableJpaAuditing
36-
static class Config extends InfrastructureConfig {
37-
38-
@Bean
39-
AuditorAwareImpl auditorAware() {
40-
return new AuditorAwareImpl();
41-
}
42-
}
4328
}

spring-data-jpa-example/src/test/java/org/springframework/data/jpa/example/repository/simple/JavaConfigSimpleUserRepositoryTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
import org.springframework.context.annotation.Configuration;
1919
import org.springframework.context.annotation.Import;
20-
import org.springframework.data.jpa.example.repository.InfrastructureConfig;
20+
import org.springframework.data.jpa.example.InfrastructureConfig;
2121
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
2222
import org.springframework.test.context.ContextConfiguration;
2323

0 commit comments

Comments
 (0)