|
28 | 28 | import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
29 | 29 | import org.springframework.context.annotation.ComponentScan;
|
30 | 30 | import org.springframework.context.annotation.Configuration;
|
| 31 | +import org.springframework.data.jpa.repository.config.EnableJpaRepositories; |
31 | 32 | import org.springframework.transaction.PlatformTransactionManager;
|
32 | 33 |
|
33 | 34 | import static org.junit.Assert.assertNotNull;
|
@@ -56,10 +57,33 @@ public void testDefaultRepositoryConfiguration() throws Exception {
|
56 | 57 | assertNotNull(this.context.getBean(EntityManagerFactory.class));
|
57 | 58 | }
|
58 | 59 |
|
| 60 | + @Test |
| 61 | + public void testOverrideRepositoryConfiguration() throws Exception { |
| 62 | + this.context = new AnnotationConfigApplicationContext(); |
| 63 | + this.context.register(CustomConfiguration.class, |
| 64 | + ComponentScanDetectorConfiguration.class, |
| 65 | + EmbeddedDataSourceConfiguration.class, |
| 66 | + HibernateJpaAutoConfiguration.class, |
| 67 | + JpaRepositoriesAutoConfiguration.class, |
| 68 | + PropertyPlaceholderAutoConfiguration.class); |
| 69 | + this.context.refresh(); |
| 70 | + assertNotNull(this.context |
| 71 | + .getBean(org.springframework.boot.autoconfigure.data.alt.CityRepository.class)); |
| 72 | + assertNotNull(this.context.getBean(PlatformTransactionManager.class)); |
| 73 | + assertNotNull(this.context.getBean(EntityManagerFactory.class)); |
| 74 | + } |
| 75 | + |
59 | 76 | @Configuration
|
60 | 77 | @ComponentScan(basePackageClasses = City.class)
|
61 | 78 | protected static class TestConfiguration {
|
62 | 79 |
|
63 | 80 | }
|
64 | 81 |
|
| 82 | + @Configuration |
| 83 | + @EnableJpaRepositories(basePackageClasses = org.springframework.boot.autoconfigure.data.alt.CityRepository.class) |
| 84 | + @ComponentScan(basePackageClasses = City.class) |
| 85 | + protected static class CustomConfiguration { |
| 86 | + |
| 87 | + } |
| 88 | + |
65 | 89 | }
|
0 commit comments