spring_reference/IV. Spring Boot features/28.1.3. Connection to a JND...

9 lines
578 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

### 28.1.3. 连接到一个JNDI数据库
如果正在将Spring Boot应用部署到一个应用服务器你可能想要用应用服务器内建的特性来配置和管理你的DataSource并使用JNDI访问它。
spring.datasource.jndi-name属性可以用来替代spring.datasource.urlspring.datasource.username和spring.datasource.password去从一个特定的JNDI路径访问DataSource。比如下面application.properties中的片段展示了如何获取JBoss定义的DataSource
```java
spring.datasource.jndi-name=java:jboss/datasources/customers
```