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
1b039e78
Commit
1b039e78
authored
Dec 17, 2014
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Documentation improvement of DataSource configuration
Closes gh-2126
parent
f6ab41df
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
3 deletions
+28
-3
howto.adoc
spring-boot-docs/src/main/asciidoc/howto.adoc
+2
-1
spring-boot-features.adoc
spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc
+26
-2
No files found.
spring-boot-docs/src/main/asciidoc/howto.adoc
View file @
1b039e78
...
...
@@ -1103,7 +1103,8 @@ samples for more detail and to see it in action.
To override the default settings just define a `@Bean` of your own of type `DataSource`.
Spring Boot provides a utility builder class `DataSourceBuilder` that can be used
to create one of the standard ones (if it is on the classpath), or you can just create
your own, and bind it to a set of `Environment` properties e.g.
your own, and bind it to a set of `Environment` properties as explained in
<<spring-boot-features.adoc#boot-features-external-config-3rd-party-configuration>>, e.g.
[source,java,indent=0,subs="verbatim,quotes,attributes"]
----
...
...
spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc
View file @
1b039e78
...
...
@@ -571,6 +571,28 @@ TIP: Using `@ConfigurationProperties` also allows you to generate meta-data file
be used by IDEs. See the <<configuration-metadata>> appendix for details.
[[boot-features-external-config-3rd-party-configuration]]
==== Third-party configuration
You can also use that feature for third-party components: in that case, you can't obviously
add a `@ConfigurationProperties` to it if you don't have access to the source code or if that
component does not know about Spring Boot.
To configure a bean from the `Environment` properties, add `@ConfigurationProperties` to its
bean registration:
[source,java,indent=0]
----
@ConfigurationProperties(prefix = "foo")
@Bean
public FooComponent fooComponent() {
...
}
----
Any property defined with the `foo` prefix will be mapped onto that `FooComponent` bean in a
similar manner as the `ConnectionSettings` example above.
[[boot-features-external-config-relaxed-binding]]
==== Relaxed binding
...
...
@@ -1416,7 +1438,7 @@ Production database connections can also be auto-configured using a pooling
* Lastly, if Commons DBCP2 is available we will use it
If you use the `spring-boot-starter-jdbc` or `spring-boot-starter-data-jpa`
'`starter POMs`' you will autom
c
atically get a dependency to `tomcat-jdbc`.
'`starter POMs`' you will automatically get a dependency to `tomcat-jdbc`.
NOTE: Additional connection pools can always be configured manually. If you define your
own `DataSource` bean, auto-configuration will not occur.
...
...
@@ -1434,7 +1456,9 @@ in `application.properties`:
----
See {sc-spring-boot-autoconfigure}/jdbc/DataSourceProperties.{sc-ext}[`DataSourceProperties`]
for more of the supported options.
for more of the supported options. Note also that you can configure any of the `DataSource`
implementation specific properties via `+spring.datasource.*+`: refer to the documentation
of the connection pool implementation you are using for more details.
TIP: You often won't need to specify the `driver-class-name` since Spring boot can deduce
it for most databases from the `url`.
...
...
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