Skip to content

Commit 5b69580

Browse files
committed
Merge branch '3.0.x' into 3.1.x
Closes gh-36004
2 parents 660dbb9 + f584d6d commit 5b69580

File tree

5 files changed

+17
-17
lines changed

5 files changed

+17
-17
lines changed

spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/testing.adoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -861,15 +861,15 @@ If you <<using#using.structuring-your-code, structure your code>> in a sensible
861861

862862
It then becomes important not to litter the application's main class with configuration settings that are specific to a particular area of its functionality.
863863

864-
Assume that you are using Spring Batch and you rely on the auto-configuration for it.
864+
Assume that you are using Spring Data MongoDB, you rely on the auto-configuration for it, and you have enabled auditing.
865865
You could define your `@SpringBootApplication` as follows:
866866

867867
include::code:MyApplication[]
868868

869-
Because this class is the source configuration for the test, any slice test actually tries to start Spring Batch, which is definitely not what you want to do.
869+
Because this class is the source configuration for the test, any slice test actually tries to enable Mongo auditing, which is definitely not what you want to do.
870870
A recommended approach is to move that area-specific configuration to a separate `@Configuration` class at the same level as your application, as shown in the following example:
871871

872-
include::code:MyBatchConfiguration[]
872+
include::code:MyMongoConfiguration[]
873873

874874
NOTE: Depending on the complexity of your application, you may either have a single `@Configuration` class for your customizations or one class per domain area.
875875
The latter approach lets you enable it in one of your tests, if necessary, with the `@Import` annotation.

spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/features/testing/springbootapplications/userconfigurationandslicing/MyApplication.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2021 the original author or authors.
2+
* Copyright 2012-2023 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.
@@ -16,11 +16,11 @@
1616

1717
package org.springframework.boot.docs.features.testing.springbootapplications.userconfigurationandslicing;
1818

19-
import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;
2019
import org.springframework.boot.autoconfigure.SpringBootApplication;
20+
import org.springframework.data.mongodb.config.EnableMongoAuditing;
2121

2222
@SpringBootApplication
23-
@EnableBatchProcessing
23+
@EnableMongoAuditing
2424
public class MyApplication {
2525

2626
// ...
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2021 the original author or authors.
2+
* Copyright 2012-2023 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.
@@ -16,12 +16,12 @@
1616

1717
package org.springframework.boot.docs.features.testing.springbootapplications.userconfigurationandslicing;
1818

19-
import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;
2019
import org.springframework.context.annotation.Configuration;
20+
import org.springframework.data.mongodb.config.EnableMongoAuditing;
2121

2222
@Configuration(proxyBeanMethods = false)
23-
@EnableBatchProcessing
24-
public class MyBatchConfiguration {
23+
@EnableMongoAuditing
24+
public class MyMongoConfiguration {
2525

2626
// ...
2727

spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/userconfigurationandslicing/MyApplication.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2022 the original author or authors.
2+
* Copyright 2012-2023 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.
@@ -16,11 +16,11 @@
1616

1717
package org.springframework.boot.docs.features.testing.springbootapplications.userconfigurationandslicing
1818

19-
import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing
2019
import org.springframework.boot.autoconfigure.SpringBootApplication
20+
import org.springframework.data.mongodb.config.EnableMongoAuditing
2121

2222
@SpringBootApplication
23-
@EnableBatchProcessing
23+
@EnableMongoAuditing
2424
class MyApplication {
2525

2626
// ...
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2022 the original author or authors.
2+
* Copyright 2012-2023 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.
@@ -16,12 +16,12 @@
1616

1717
package org.springframework.boot.docs.features.testing.springbootapplications.userconfigurationandslicing
1818

19-
import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing
2019
import org.springframework.context.annotation.Configuration
20+
import org.springframework.data.mongodb.config.EnableMongoAuditing;
2121

2222
@Configuration(proxyBeanMethods = false)
23-
@EnableBatchProcessing
24-
class MyBatchConfiguration {
23+
@EnableMongoAuditing
24+
class MyMongoConfiguration {
2525

2626
// ...
2727

0 commit comments

Comments
 (0)