Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
2377bd9e
Commit
2377bd9e
authored
Jan 09, 2014
by
Dave Syer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't load BatchAutoConfiguration at all if there is no JobLauncher
Fixes gh-204
parent
b1db714c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
4 deletions
+21
-4
BatchAutoConfiguration.java
...work/boot/autoconfigure/batch/BatchAutoConfiguration.java
+1
-2
BatchAutoConfigurationTests.java
...boot/autoconfigure/batch/BatchAutoConfigurationTests.java
+20
-2
No files found.
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfiguration.java
View file @
2377bd9e
...
...
@@ -54,6 +54,7 @@ import org.springframework.util.StringUtils;
@Configuration
@ConditionalOnClass
({
JobLauncher
.
class
,
DataSource
.
class
,
JdbcOperations
.
class
})
@AutoConfigureAfter
(
HibernateJpaAutoConfiguration
.
class
)
@ConditionalOnBean
(
JobLauncher
.
class
)
public
class
BatchAutoConfiguration
{
@Value
(
"${spring.batch.job.name:}"
)
...
...
@@ -70,7 +71,6 @@ public class BatchAutoConfiguration {
@Bean
@ConditionalOnMissingBean
@ConditionalOnBean
(
JobLauncher
.
class
)
@ConditionalOnExpression
(
"${spring.batch.job.enabled:true}"
)
public
JobLauncherCommandLineRunner
jobLauncherCommandLineRunner
()
{
JobLauncherCommandLineRunner
runner
=
new
JobLauncherCommandLineRunner
();
...
...
@@ -82,7 +82,6 @@ public class BatchAutoConfiguration {
@Bean
@ConditionalOnMissingBean
@ConditionalOnBean
(
JobLauncher
.
class
)
public
ExitCodeGenerator
jobExecutionExitCodeGenerator
()
{
return
new
JobExecutionExitCodeGenerator
();
}
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfigurationTests.java
View file @
2377bd9e
...
...
@@ -48,6 +48,7 @@ import org.springframework.boot.test.EnvironmentTestUtils;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.ComponentScan
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.jdbc.BadSqlGrammarException
;
import
org.springframework.jdbc.core.JdbcTemplate
;
import
org.springframework.transaction.PlatformTransactionManager
;
...
...
@@ -89,6 +90,17 @@ public class BatchAutoConfigurationTests {
.
queryForList
(
"select * from BATCH_JOB_EXECUTION"
).
size
());
}
@Test
public
void
testNoBatchConfiguration
()
throws
Exception
{
this
.
context
=
new
AnnotationConfigApplicationContext
();
this
.
context
.
register
(
EmptyConfiguration
.
class
,
BatchAutoConfiguration
.
class
,
EmbeddedDataSourceConfiguration
.
class
,
PropertyPlaceholderAutoConfiguration
.
class
);
this
.
context
.
refresh
();
assertEquals
(
0
,
this
.
context
.
getBeanNamesForType
(
JobLauncher
.
class
).
length
);
assertEquals
(
0
,
this
.
context
.
getBeanNamesForType
(
JobRepository
.
class
).
length
);
}
@Test
public
void
testDefinesAndLaunchesJob
()
throws
Exception
{
this
.
context
=
new
AnnotationConfigApplicationContext
();
...
...
@@ -105,7 +117,8 @@ public class BatchAutoConfigurationTests {
@Test
public
void
testDisableLaunchesJob
()
throws
Exception
{
this
.
context
=
new
AnnotationConfigApplicationContext
();
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"spring.batch.job.enabled:false"
);
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"spring.batch.job.enabled:false"
);
this
.
context
.
register
(
JobConfiguration
.
class
,
BatchAutoConfiguration
.
class
,
EmbeddedDataSourceConfiguration
.
class
,
PropertyPlaceholderAutoConfiguration
.
class
);
...
...
@@ -117,7 +130,8 @@ public class BatchAutoConfigurationTests {
@Test
public
void
testDisableSchemaLoader
()
throws
Exception
{
this
.
context
=
new
AnnotationConfigApplicationContext
();
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"spring.datasource.name:batchtest"
,
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"spring.datasource.name:batchtest"
,
"spring.batch.initializer.enabled:false"
);
this
.
context
.
register
(
TestConfiguration
.
class
,
BatchAutoConfiguration
.
class
,
EmbeddedDataSourceConfiguration
.
class
,
...
...
@@ -149,6 +163,10 @@ public class BatchAutoConfigurationTests {
new
JobParameters
()));
}
@Configuration
protected
static
class
EmptyConfiguration
{
}
@EnableBatchProcessing
@ComponentScan
(
basePackageClasses
=
City
.
class
)
protected
static
class
TestConfiguration
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment