Skip to content
This repository was archived by the owner on Apr 4, 2025. It is now read-only.

Commit e8d12b5

Browse files
vpavicgregturn
authored andcommitted
Refactor ReactiveMongoWebSessionConfiguration to support Spring Boot
This commit updates `ReactiveMongoWebSessionConfiguration` to extend `SpringWebSessionConfiguration` rather than having it imported via `@EnableMongoWebSession`. This is required in order for Spring Boot auto-configuration to work properly.
1 parent 7b47d32 commit e8d12b5

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

src/main/java/org/springframework/session/data/mongo/config/annotation/web/reactive/EnableMongoWebSession.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
import org.springframework.context.annotation.Configuration;
2323
import org.springframework.context.annotation.Import;
24-
import org.springframework.session.config.annotation.web.server.EnableSpringWebSession;
2524
import org.springframework.session.data.mongo.ReactiveMongoOperationsSessionRepository;
2625

2726
/**
@@ -45,12 +44,12 @@
4544
* </pre>
4645
*
4746
* @author Greg Turnquist
47+
* @author Vedran Pavić
4848
* @since 2.0
4949
*/
5050
@Retention(java.lang.annotation.RetentionPolicy.RUNTIME)
5151
@Target({ java.lang.annotation.ElementType.TYPE })
5252
@Documented
53-
@EnableSpringWebSession
5453
@Import(ReactiveMongoWebSessionConfiguration.class)
5554
@Configuration
5655
public @interface EnableMongoWebSession {

src/main/java/org/springframework/session/data/mongo/config/annotation/web/reactive/ReactiveMongoWebSessionConfiguration.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.springframework.core.type.AnnotationMetadata;
2525
import org.springframework.data.mongodb.core.MongoOperations;
2626
import org.springframework.data.mongodb.core.ReactiveMongoOperations;
27+
import org.springframework.session.config.annotation.web.server.SpringWebSessionConfiguration;
2728
import org.springframework.session.data.mongo.AbstractMongoSessionConverter;
2829
import org.springframework.session.data.mongo.ReactiveMongoOperationsSessionRepository;
2930
import org.springframework.util.StringUtils;
@@ -33,9 +34,11 @@
3334
* Configure a {@link ReactiveMongoOperationsSessionRepository} using a provided {@link ReactiveMongoOperations}.
3435
*
3536
* @author Greg Turnquist
37+
* @author Vedran Pavić
3638
*/
3739
@Configuration
38-
public class ReactiveMongoWebSessionConfiguration implements EmbeddedValueResolverAware, ImportAware {
40+
public class ReactiveMongoWebSessionConfiguration extends SpringWebSessionConfiguration
41+
implements EmbeddedValueResolverAware, ImportAware {
3942

4043
private AbstractMongoSessionConverter mongoSessionConverter;
4144
private Integer maxInactiveIntervalInSeconds;

src/test/java/org/springframework/session/data/mongo/config/annotation/web/reactive/ReactiveMongoWebSessionConfigurationTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
* Verify various configurations through {@link EnableSpringWebSession}.
4848
*
4949
* @author Greg Turnquist
50+
* @author Vedran Pavić
5051
*/
5152
public class ReactiveMongoWebSessionConfigurationTest {
5253

@@ -85,7 +86,7 @@ public void missingReactorSessionRepositoryBreaksAppContext() {
8586

8687
assertThatExceptionOfType(UnsatisfiedDependencyException.class)
8788
.isThrownBy(this.context::refresh)
88-
.withMessageContaining("Error creating bean with name 'webSessionManager'")
89+
.withMessageContaining("Error creating bean with name 'reactiveMongoOperationsSessionRepository'")
8990
.withMessageContaining("No qualifying bean of type '" + ReactiveMongoOperations.class.getCanonicalName());
9091
}
9192

0 commit comments

Comments
 (0)