Add property for JNDI DataSource lookup
Add `spring.datasource.jndi-name` property to allow a DataSource to be looked up from JNDI as an alternative to defining a URL connection. Fixes gh-989
This commit is contained in:
@@ -175,6 +175,7 @@ content into your application; rather pick only the properties that you need.
|
||||
spring.datasource.url=
|
||||
spring.datasource.username=
|
||||
spring.datasource.password=
|
||||
spring.datasource.jndi-name # For JNDI lookup (class, url, username & password are ignored when set)
|
||||
spring.datasource.max-active=100 # Advanced configuration...
|
||||
spring.datasource.max-idle=8
|
||||
spring.datasource.min-idle=8
|
||||
|
||||
@@ -1272,6 +1272,27 @@ NOTE: For a pooling `DataSource` to be created we need to be able to verify that
|
||||
`spring.datasource.driverClassName=com.mysql.jdbc.Driver` then that class has to be
|
||||
loadable.
|
||||
|
||||
|
||||
|
||||
[[boot-features-connecting-to-a-jndi-datasource]]
|
||||
==== Connection to a JNDI DataSource
|
||||
If you are deploying your Spring Boot application to an Application Server you might want
|
||||
to configure and manage your DataSource using you Application Servers built in features
|
||||
and access it using JNDI.
|
||||
|
||||
The `spring.datasource.jndi-name` property can be used as an alternative to the
|
||||
`spring.datasource.url`, `spring.datasource.username` and `spring.datasource.password`
|
||||
properties to access the `DataSource` from a specific JNDI location. For example, the
|
||||
following section in `application.properties` shows how you can access a JBoss AS defined
|
||||
`DataSource`:
|
||||
|
||||
[source,properties,indent=0]
|
||||
----
|
||||
spring.datasource.jndi-name=java:jboss/datasources/customers
|
||||
----
|
||||
|
||||
|
||||
|
||||
[[boot-features-using-jdbc-template]]
|
||||
=== Using JdbcTemplate
|
||||
Spring's `JdbcTemplate` and `NamedParameterJdbcTemplate` classes are auto-configured and
|
||||
|
||||
Reference in New Issue
Block a user