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
15375fdf
Commit
15375fdf
authored
Feb 17, 2021
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2.4.x'
Closes gh-25342
parents
274a985e
5d1bb302
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
2 deletions
+14
-2
DataSourceBuilder.java
...java/org/springframework/boot/jdbc/DataSourceBuilder.java
+3
-1
DataSourceBuilderTests.java
...org/springframework/boot/jdbc/DataSourceBuilderTests.java
+11
-1
No files found.
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/DataSourceBuilder.java
View file @
15375fdf
/*
* Copyright 2012-202
0
the original author or authors.
* Copyright 2012-202
1
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -196,6 +196,8 @@ public final class DataSourceBuilder<T extends DataSource> {
(
aliases
)
->
aliases
.
addAliases
(
"driver-class-name"
,
"driver-class"
))));
addIfAvailable
(
this
.
allDataSourceSettings
,
create
(
classLoader
,
"oracle.jdbc.datasource.OracleDataSource"
,
OracleDataSourceSettings:
:
new
));
addIfAvailable
(
this
.
allDataSourceSettings
,
create
(
classLoader
,
"org.h2.jdbcx.JdbcDataSource"
,
(
type
)
->
new
DataSourceSettings
(
type
,
(
aliases
)
->
aliases
.
addAliases
(
"username"
,
"user"
))));
}
private
static
List
<
DataSourceSettings
>
resolveAvailableDataSourceSettings
(
ClassLoader
classLoader
)
{
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/jdbc/DataSourceBuilderTests.java
View file @
15375fdf
/*
* Copyright 2012-202
0
the original author or authors.
* Copyright 2012-202
1
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -30,6 +30,7 @@ import oracle.jdbc.pool.OracleDataSource;
import
oracle.ucp.jdbc.PoolDataSourceImpl
;
import
org.apache.commons.dbcp2.BasicDataSource
;
import
org.h2.Driver
;
import
org.h2.jdbcx.JdbcDataSource
;
import
org.junit.jupiter.api.AfterEach
;
import
org.junit.jupiter.api.Test
;
...
...
@@ -119,6 +120,15 @@ class DataSourceBuilderTests {
assertThat
(
upcDataSource
.
getUser
()).
isEqualTo
(
"test"
);
}
@Test
void
dataSourceCanBeCreatedWithH2JdbcDataSource
()
{
this
.
dataSource
=
DataSourceBuilder
.
create
().
url
(
"jdbc:h2:test"
).
type
(
JdbcDataSource
.
class
).
username
(
"test"
)
.
build
();
assertThat
(
this
.
dataSource
).
isInstanceOf
(
JdbcDataSource
.
class
);
JdbcDataSource
h2DataSource
=
(
JdbcDataSource
)
this
.
dataSource
;
assertThat
(
h2DataSource
.
getUser
()).
isEqualTo
(
"test"
);
}
@Test
void
dataSourceAliasesAreOnlyAppliedToRelevantDataSource
()
{
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