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
548ca630
Commit
548ca630
authored
Feb 18, 2021
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2.4.x'
Closes gh-25364
parents
8ec14e28
526474f3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
0 deletions
+12
-0
DataSourceBuilder.java
...java/org/springframework/boot/jdbc/DataSourceBuilder.java
+2
-0
DataSourceBuilderTests.java
...org/springframework/boot/jdbc/DataSourceBuilderTests.java
+10
-0
No files found.
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/DataSourceBuilder.java
View file @
548ca630
...
@@ -198,6 +198,8 @@ public final class DataSourceBuilder<T extends DataSource> {
...
@@ -198,6 +198,8 @@ public final class DataSourceBuilder<T extends DataSource> {
create
(
classLoader
,
"oracle.jdbc.datasource.OracleDataSource"
,
OracleDataSourceSettings:
:
new
));
create
(
classLoader
,
"oracle.jdbc.datasource.OracleDataSource"
,
OracleDataSourceSettings:
:
new
));
addIfAvailable
(
this
.
allDataSourceSettings
,
create
(
classLoader
,
"org.h2.jdbcx.JdbcDataSource"
,
addIfAvailable
(
this
.
allDataSourceSettings
,
create
(
classLoader
,
"org.h2.jdbcx.JdbcDataSource"
,
(
type
)
->
new
DataSourceSettings
(
type
,
(
aliases
)
->
aliases
.
addAliases
(
"username"
,
"user"
))));
(
type
)
->
new
DataSourceSettings
(
type
,
(
aliases
)
->
aliases
.
addAliases
(
"username"
,
"user"
))));
addIfAvailable
(
this
.
allDataSourceSettings
,
create
(
classLoader
,
"org.postgresql.ds.PGSimpleDataSource"
,
(
type
)
->
new
DataSourceSettings
(
type
,
(
aliases
)
->
aliases
.
addAliases
(
"username"
,
"user"
))));
}
}
private
static
List
<
DataSourceSettings
>
resolveAvailableDataSourceSettings
(
ClassLoader
classLoader
)
{
private
static
List
<
DataSourceSettings
>
resolveAvailableDataSourceSettings
(
ClassLoader
classLoader
)
{
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/jdbc/DataSourceBuilderTests.java
View file @
548ca630
...
@@ -33,6 +33,7 @@ import org.h2.Driver;
...
@@ -33,6 +33,7 @@ import org.h2.Driver;
import
org.h2.jdbcx.JdbcDataSource
;
import
org.h2.jdbcx.JdbcDataSource
;
import
org.junit.jupiter.api.AfterEach
;
import
org.junit.jupiter.api.AfterEach
;
import
org.junit.jupiter.api.Test
;
import
org.junit.jupiter.api.Test
;
import
org.postgresql.ds.PGSimpleDataSource
;
import
org.springframework.jdbc.datasource.SimpleDriverDataSource
;
import
org.springframework.jdbc.datasource.SimpleDriverDataSource
;
...
@@ -129,6 +130,15 @@ class DataSourceBuilderTests {
...
@@ -129,6 +130,15 @@ class DataSourceBuilderTests {
assertThat
(
h2DataSource
.
getUser
()).
isEqualTo
(
"test"
);
assertThat
(
h2DataSource
.
getUser
()).
isEqualTo
(
"test"
);
}
}
@Test
void
dataSourceCanBeCreatedWithPGDataSource
()
{
this
.
dataSource
=
DataSourceBuilder
.
create
().
url
(
"jdbc:postgresql://localhost/test"
)
.
type
(
PGSimpleDataSource
.
class
).
username
(
"test"
).
build
();
assertThat
(
this
.
dataSource
).
isInstanceOf
(
PGSimpleDataSource
.
class
);
PGSimpleDataSource
pgDataSource
=
(
PGSimpleDataSource
)
this
.
dataSource
;
assertThat
(
pgDataSource
.
getUser
()).
isEqualTo
(
"test"
);
}
@Test
@Test
void
dataSourceAliasesAreOnlyAppliedToRelevantDataSource
()
{
void
dataSourceAliasesAreOnlyAppliedToRelevantDataSource
()
{
this
.
dataSource
=
DataSourceBuilder
.
create
().
url
(
"jdbc:h2:test"
).
type
(
TestDataSource
.
class
).
username
(
"test"
)
this
.
dataSource
=
DataSourceBuilder
.
create
().
url
(
"jdbc:h2:test"
).
type
(
TestDataSource
.
class
).
username
(
"test"
)
...
...
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