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
acd9b61c
Commit
acd9b61c
authored
Jul 09, 2019
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make Batch JPA auto-configuration back off without a DataSource
Fixes gh-17465
parent
c5241f0e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
1 deletion
+18
-1
BatchConfigurerConfiguration.java
...oot/autoconfigure/batch/BatchConfigurerConfiguration.java
+1
-1
BatchAutoConfigurationTests.java
...boot/autoconfigure/batch/BatchAutoConfigurationTests.java
+17
-0
No files found.
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BatchConfigurerConfiguration.java
View file @
acd9b61c
...
@@ -35,12 +35,12 @@ import org.springframework.transaction.PlatformTransactionManager;
...
@@ -35,12 +35,12 @@ import org.springframework.transaction.PlatformTransactionManager;
* @author Stephane Nicoll
* @author Stephane Nicoll
*/
*/
@ConditionalOnClass
(
PlatformTransactionManager
.
class
)
@ConditionalOnClass
(
PlatformTransactionManager
.
class
)
@ConditionalOnBean
(
DataSource
.
class
)
@ConditionalOnMissingBean
(
BatchConfigurer
.
class
)
@ConditionalOnMissingBean
(
BatchConfigurer
.
class
)
@Configuration
@Configuration
class
BatchConfigurerConfiguration
{
class
BatchConfigurerConfiguration
{
@Configuration
@Configuration
@ConditionalOnBean
(
DataSource
.
class
)
@ConditionalOnMissingBean
(
name
=
"entityManagerFactory"
)
@ConditionalOnMissingBean
(
name
=
"entityManagerFactory"
)
static
class
JdbcBatchConfiguration
{
static
class
JdbcBatchConfiguration
{
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfigurationTests.java
View file @
acd9b61c
...
@@ -61,6 +61,7 @@ import org.springframework.transaction.PlatformTransactionManager;
...
@@ -61,6 +61,7 @@ import org.springframework.transaction.PlatformTransactionManager;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThatExceptionOfType
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThatExceptionOfType
;
import
static
org
.
mockito
.
Mockito
.
mock
;
/**
/**
* Tests for {@link BatchAutoConfiguration}.
* Tests for {@link BatchAutoConfiguration}.
...
@@ -94,6 +95,12 @@ public class BatchAutoConfigurationTests {
...
@@ -94,6 +95,12 @@ public class BatchAutoConfigurationTests {
.
run
((
context
)
->
assertThat
(
context
).
doesNotHaveBean
(
BatchConfigurer
.
class
));
.
run
((
context
)
->
assertThat
(
context
).
doesNotHaveBean
(
BatchConfigurer
.
class
));
}
}
@Test
public
void
whenThereIsAnEntityManagerFactoryButNoDataSourceAutoConfigurationBacksOff
()
{
this
.
contextRunner
.
withUserConfiguration
(
TestConfiguration
.
class
,
EntityManagerFactoryConfiguration
.
class
)
.
run
((
context
)
->
assertThat
(
context
).
doesNotHaveBean
(
BatchConfigurer
.
class
));
}
@Test
@Test
public
void
testCustomConfigurationWithNoDatabase
()
{
public
void
testCustomConfigurationWithNoDatabase
()
{
this
.
contextRunner
.
withUserConfiguration
(
TestCustomConfiguration
.
class
).
run
((
context
)
->
{
this
.
contextRunner
.
withUserConfiguration
(
TestCustomConfiguration
.
class
).
run
((
context
)
->
{
...
@@ -250,6 +257,16 @@ public class BatchAutoConfigurationTests {
...
@@ -250,6 +257,16 @@ public class BatchAutoConfigurationTests {
}
}
@Configuration
static
class
EntityManagerFactoryConfiguration
{
@Bean
EntityManagerFactory
entityManagerFactory
()
{
return
mock
(
EntityManagerFactory
.
class
);
}
}
@EnableBatchProcessing
@EnableBatchProcessing
@TestAutoConfigurationPackage
(
City
.
class
)
@TestAutoConfigurationPackage
(
City
.
class
)
protected
static
class
TestCustomConfiguration
implements
BatchConfigurer
{
protected
static
class
TestCustomConfiguration
implements
BatchConfigurer
{
...
...
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