Skip to content

Commit 71601c3

Browse files
committed
Merge branch '1.4.x' into 1.5.x
2 parents cd51240 + 2cf93f8 commit 71601c3

File tree

10 files changed

+21
-35
lines changed

10 files changed

+21
-35
lines changed

spring-boot-docs/src/main/asciidoc/howto.adoc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1702,11 +1702,10 @@ You can apply the same principle if you are configuring a custom JNDI `DataSourc
17021702
}
17031703
----
17041704

1705-
1706-
Spring Boot also provides a utility builder class `DataSourceBuilder` that can be used
1707-
to create one of the standard data sources (if it is on the classpath). The builder can
1708-
detect the one to use based on the ones available on the classpath and it also auto
1709-
detects the driver based on the JDBC url.
1705+
Spring Boot also provides a utility builder class `DataSourceBuilder` that can be used to
1706+
create one of the standard data sources (if it is on the classpath). The builder can
1707+
detect the one to use based on what's available on the classpath. It also auto detects the
1708+
driver based on the JDBC url.
17101709

17111710
[source,java,indent=0,subs="verbatim,quotes,attributes"]
17121711
----
@@ -1729,7 +1728,7 @@ There is a catch however. Because the actual type of the connection pool is not
17291728
no keys are generated in the metadata for your custom `DataSource` and no completion is
17301729
available in your IDE (The `DataSource` interface doesn't expose any property). Also, if
17311730
you happen to _only_ have Hikari on the classpath, this basic setup will not work because
1732-
Hikari has no `url` parameter (but a `jdbcUrl` parameter). You should have to rewrite
1731+
Hikari has no `url` parameter (but a `jdbcUrl` parameter). You will have to rewrite
17331732
your configuration as follows:
17341733

17351734
[source,properties,indent=0]
@@ -1831,6 +1830,7 @@ This final example configures two data sources on custom namespaces with the sam
18311830
than what Spring Boot would do in auto-configuration.
18321831

18331832

1833+
18341834
[[howto-use-spring-data-repositories]]
18351835
=== Use Spring Data repositories
18361836
Spring Data can create implementations for you of `@Repository` interfaces of various

spring-boot-docs/src/main/java/org/springframework/boot/jdbc/BasicDataSourceExample.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,5 @@ public DataSource dataSource() {
4545
// end::configuration[]
4646

4747
}
48+
4849
}

spring-boot-docs/src/main/java/org/springframework/boot/jdbc/CompleteTwoDataSourcesExample.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
import org.springframework.context.annotation.Primary;
2626

2727
/**
28-
* Example configuration for configuring two data sources with what Spring Boot does
29-
* in auto-configuration.
28+
* Example configuration for configuring two data sources with what Spring Boot does in
29+
* auto-configuration.
3030
*
3131
* @author Stephane Nicoll
3232
*/
@@ -50,9 +50,7 @@ public DataSourceProperties fooDataSourceProperties() {
5050
@Primary
5151
@ConfigurationProperties("app.datasource.foo")
5252
public DataSource fooDataSource() {
53-
return fooDataSourceProperties()
54-
.initializeDataSourceBuilder()
55-
.build();
53+
return fooDataSourceProperties().initializeDataSourceBuilder().build();
5654
}
5755

5856
@Bean
@@ -61,13 +59,10 @@ public DataSourceProperties barDataSourceProperties() {
6159
return new DataSourceProperties();
6260
}
6361

64-
6562
@Bean
6663
@ConfigurationProperties("app.datasource.bar")
6764
public DataSource barDataSource() {
68-
return barDataSourceProperties()
69-
.initializeDataSourceBuilder()
70-
.build();
65+
return barDataSourceProperties().initializeDataSourceBuilder().build();
7166
}
7267
// end::configuration[]
7368

spring-boot-docs/src/main/java/org/springframework/boot/jdbc/ConfigurableDataSourceExample.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ public DataSourceProperties dataSourceProperties() {
5252
@ConfigurationProperties("app.datasource")
5353
public HikariDataSource dataSource(DataSourceProperties properties) {
5454
return (HikariDataSource) properties.initializeDataSourceBuilder()
55-
.type(HikariDataSource.class)
56-
.build();
55+
.type(HikariDataSource.class).build();
5756
}
5857
// end::configuration[]
5958

6059
}
60+
6161
}

spring-boot-docs/src/main/java/org/springframework/boot/jdbc/SimpleDataSourceExample.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ static class SimpleDataSourceConfiguration {
4343
@ConfigurationProperties("app.datasource")
4444
public HikariDataSource dataSource() {
4545
return (HikariDataSource) DataSourceBuilder.create()
46-
.type(HikariDataSource.class)
47-
.build();
46+
.type(HikariDataSource.class).build();
4847
}
4948
// end::configuration[]
5049

spring-boot-docs/src/main/java/org/springframework/boot/jdbc/SimpleTwoDataSourcesExample.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,14 @@ public DataSourceProperties fooDataSourceProperties() {
5353
@Primary
5454
@ConfigurationProperties("app.datasource.foo")
5555
public DataSource fooDataSource() {
56-
return fooDataSourceProperties()
57-
.initializeDataSourceBuilder()
58-
.build();
56+
return fooDataSourceProperties().initializeDataSourceBuilder().build();
5957
}
6058

61-
6259
@Bean
6360
@ConfigurationProperties("app.datasource.bar")
6461
public BasicDataSource barDataSource() {
6562
return (BasicDataSource) DataSourceBuilder.create()
66-
.type(BasicDataSource.class)
67-
.build();
63+
.type(BasicDataSource.class).build();
6864
}
6965
// end::configuration[]
7066

spring-boot-docs/src/test/java/org/springframework/boot/jdbc/BasicDataSourceExampleTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
/**
3535
* Test for {@link BasicDataSourceExample}.
36+
*
3637
* @author Stephane Nicoll
3738
*/
3839
@RunWith(SpringRunner.class)

spring-boot-docs/src/test/java/org/springframework/boot/jdbc/CompleteTwoDataSourcesExampleTests.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,10 @@ public class CompleteTwoDataSourcesExampleTests {
4747
@Test
4848
public void validateConfiguration() throws SQLException {
4949
assertThat(this.context.getBeansOfType(DataSource.class)).hasSize(2);
50-
5150
DataSource dataSource = this.context.getBean(DataSource.class);
5251
assertThat(this.context.getBean("fooDataSource")).isSameAs(dataSource);
5352
assertThat(dataSource.getConnection().getMetaData().getURL())
5453
.startsWith("jdbc:h2:mem:");
55-
5654
DataSource barDataSource = this.context.getBean("barDataSource",
5755
DataSource.class);
5856
assertThat(barDataSource.getConnection().getMetaData().getURL())

spring-boot-docs/src/test/java/org/springframework/boot/jdbc/SampleApp.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
2424

2525
/**
26-
* A sample {@link SpringBootConfiguration} that only enables the auto-configuration
27-
* for the {@link DataSource}.
26+
* A sample {@link SpringBootConfiguration} that only enables the auto-configuration for
27+
* the {@link DataSource}.
2828
*
2929
* @author Stephane Nicoll
3030
*/

spring-boot-docs/src/test/java/org/springframework/boot/jdbc/SimpleTwoDataSourcesExampleTests.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@
3838
* @author Stephane Nicoll
3939
*/
4040
@RunWith(SpringRunner.class)
41-
@SpringBootTest(properties = {
42-
"app.datasource.bar.url=jdbc:h2:mem:bar;DB_CLOSE_DELAY=-1",
41+
@SpringBootTest(properties = { "app.datasource.bar.url=jdbc:h2:mem:bar;DB_CLOSE_DELAY=-1",
4342
"app.datasource.bar.max-total=42" })
4443
@Import(SimpleTwoDataSourcesExample.SimpleDataSourcesConfiguration.class)
4544
public class SimpleTwoDataSourcesExampleTests {
@@ -50,16 +49,13 @@ public class SimpleTwoDataSourcesExampleTests {
5049
@Test
5150
public void validateConfiguration() throws SQLException {
5251
assertThat(this.context.getBeansOfType(DataSource.class)).hasSize(2);
53-
5452
DataSource dataSource = this.context.getBean(DataSource.class);
5553
assertThat(this.context.getBean("fooDataSource")).isSameAs(dataSource);
5654
assertThat(dataSource.getConnection().getMetaData().getURL())
5755
.startsWith("jdbc:h2:mem:");
58-
5956
BasicDataSource barDataSource = this.context.getBean("barDataSource",
6057
BasicDataSource.class);
61-
assertThat(barDataSource.getUrl())
62-
.isEqualTo("jdbc:h2:mem:bar;DB_CLOSE_DELAY=-1");
58+
assertThat(barDataSource.getUrl()).isEqualTo("jdbc:h2:mem:bar;DB_CLOSE_DELAY=-1");
6359
assertThat(barDataSource.getMaxTotal()).isEqualTo(42);
6460
}
6561

0 commit comments

Comments
 (0)