Commit 73fc351 1 parent 3cae5c2 commit 73fc351 Copy full SHA for 73fc351
File tree 2 files changed +29
-0
lines changed
spring-boot-project/spring-boot-autoconfigure/src
main/java/org/springframework/boot/autoconfigure/batch
test/java/org/springframework/boot/autoconfigure/batch
2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change 20
20
21
21
import javax .sql .DataSource ;
22
22
23
+ import org .springframework .batch .core .configuration .BatchConfigurationException ;
23
24
import org .springframework .batch .core .configuration .annotation .EnableBatchProcessing ;
24
25
import org .springframework .batch .core .configuration .support .DefaultBatchConfiguration ;
25
26
import org .springframework .batch .core .explore .JobExplorer ;
@@ -129,6 +130,13 @@ protected DataSource getDataSource() {
129
130
return this .dataSource ;
130
131
}
131
132
133
+ @ Bean
134
+ @ ConditionalOnMissingBean
135
+ @ Override
136
+ public JobRepository jobRepository () throws BatchConfigurationException {
137
+ return super .jobRepository ();
138
+ }
139
+
132
140
@ Override
133
141
protected PlatformTransactionManager getTransactionManager () {
134
142
return this .transactionManager ;
Original file line number Diff line number Diff line change @@ -517,6 +517,13 @@ void defaultExecutionContextSerializerIsUsed() {
517
517
});
518
518
}
519
519
520
+ @ Test
521
+ void defaultJobRepositoryIsNotCreatedWhenUserDefinedJobRepositoryBean () {
522
+ this .contextRunner
523
+ .withUserConfiguration (TestConfigurationWithJobRepository .class , EmbeddedDataSourceConfiguration .class )
524
+ .run ((context ) -> assertThat (context ).hasSingleBean (TestJobRepository .class ));
525
+ }
526
+
520
527
private JobLauncherApplicationRunner createInstance (String ... registeredJobNames ) {
521
528
JobLauncherApplicationRunner runner = new JobLauncherApplicationRunner (mock (JobLauncher .class ),
522
529
mock (JobExplorer .class ), mock (JobRepository .class ));
@@ -596,6 +603,16 @@ static class TestConfiguration {
596
603
597
604
}
598
605
606
+ @ TestAutoConfigurationPackage (City .class )
607
+ static class TestConfigurationWithJobRepository {
608
+
609
+ @ Bean
610
+ TestJobRepository jobRepository () {
611
+ return mock (TestJobRepository .class );
612
+ }
613
+
614
+ }
615
+
599
616
@ Configuration (proxyBeanMethods = false )
600
617
static class EntityManagerFactoryConfiguration {
601
618
@@ -880,4 +897,8 @@ ExecutionContextSerializer executionContextSerializer() {
880
897
881
898
}
882
899
900
+ interface TestJobRepository extends JobRepository {
901
+
902
+ }
903
+
883
904
}
You can’t perform that action at this time.
0 commit comments