Skip to content

Commit 13f5cb4

Browse files
committed
Document @SpringSessionDataSource in reference docs
Issue gh-1011
1 parent 5c05970 commit 13f5cb4

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

spring-session-docs/src/docs/asciidoc/guides/java-jdbc.adoc

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,36 @@ Doing so ensures that the Spring bean named `springSessionRepositoryFilter` is r
128128
<2> `AbstractHttpSessionApplicationInitializer` also provides a mechanism to ensure Spring loads our `Config`.
129129
====
130130

131+
== Multiple DataSources
132+
Spring Session provides the `@SpringSessionDataSource` qualifier, allowing you to explicitly declare which `DataSource` bean should be injected in `JdbcIndexedSessionRepository`.
133+
This is particularly useful in scenarios with multiple `DataSource` beans present in the application context.
134+
135+
The following example shows how to do so:
136+
137+
====
138+
.Config.java
139+
[source,java]
140+
----
141+
@EnableJdbcHttpSession
142+
public class Config {
143+
144+
@Bean
145+
@SpringSessionDataSource // <1>
146+
public EmbeddedDatabase firstDataSource() {
147+
return new EmbeddedDatabaseBuilder()
148+
.setType(EmbeddedDatabaseType.H2).addScript("org/springframework/session/jdbc/schema-h2.sql").build();
149+
}
150+
151+
@Bean
152+
public HikariDataSource secondDataSource() {
153+
// ...
154+
}
155+
}
156+
----
157+
158+
<1> This qualifier declares that firstDataSource is to be used by Spring Session.
159+
====
160+
131161
// end::config[]
132162

133163
[[httpsession-jdbc-sample]]

0 commit comments

Comments
 (0)