Day 8 Spring Boot Database
In the knowledge lies the power——Edward Albert Feigenbaum(图灵奖获得者)
The Spring Framework provides extensive
support for working with SQL databases, from direct
JDBC access
to complete
“object relational mapping”
technologies.
Spring框架提供了大量的数据库相关的支持,从最直接的JDBC链接,到完整的“对象关系映射”技术。
Spring Data provides an additional
level of functionality:
creating Repository
implementations
directly
from interfaces and using conventions
to generate
queries from your method names
.
Spring Data模块还提供了一个更高级别的功能:它能通过接口文件来直接创建Repository的实现类,还可以根据惯例和方法名生成数据查询请求。
It is often convenient
to develop
applications
by using an in-memory embedded database
.
使用内存数据库便于开发应用。
Obviously
, in-memory databases do not provide persistent
storage
.
显然,内存数据库无法提供持久数据存储。
You need to populate
your database when your application
starts and be prepared to throw away
data when your application
ends.
当应用启动时,你需要填充数据;当应用关闭时,对即将丢失的数据要有准备。
Spring Boot can auto-configure
embedded databases
. You need not provide any connection
URLs. You need only include a build dependency
to the embedded database
that you want to use.
Spring Boot 可以自动配置嵌入式数据库。你甚至都不需要提供链接地址,只需要在编译依赖中加入你想使用的嵌入式数据库。
If, for whatever reason, you do configure the connection
URL for an embedded database
, take care to ensure
that the database’s automatic
shutdown
is disabled
.
不管出于什么原因,如果你一定要给嵌入式数据库配置链接地址,务必确保禁用数据库的自动关闭功能。
Disabling the database’s automatic
shutdown
lets Spring Boot control when the database is closed, thereby
ensuring that it happens once access
to the database is no longer needed.
数据库的自动关闭功能被禁用后,Spring Boot才能控制数据库应该何时被关闭,从而确保在应用不再需要访问数据库时,数据库可以被正确地关闭掉。
本文选自:
https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-sql.html
生词 | 音标 | 释义 |
---|---|---|
extensive | [ɪkˈstɛnsɪv] | adj. 广阔的 |
direct | [dɪˈrɛkt] | adj. 直接的 |
complete | [kəmˈplit] | adj. 完整的 |
object relational mapping | 对象-关系映射 | |
additional | [ə'dɪʃənl] | adj. 附加的 |
functionality | [ˌfʌŋkʃəˈnælɪti] | n. 功能 |
repository | [rɪˈpɑ:zətɔ:ri] | n. 仓库 |
implementation | [ˌɪmplɪmənˈteʃən] | n. 实现 |
convention | [kənˈvɛnʃən] | n. 惯例 |
generate | [ˈdʒɛnəˌret] | n. 生成 |
query | [ˈkwɪri] | n. 查询表 |
method name | 方法名 | |
convenient | [kənˈvinjənt] | adj. 方便的 |
develop | [dɪˈvɛləp] | v. 开发 |
application | [ˌæplɪˈkeʃən] | n. 应用 |
embedded database | 嵌入式数据库 | |
obviously | [ˈɑ:bviəsli] | adj. 明显的 |
persistent | [pərˈsɪstənt] | adj. 持久的 |
storage | [ˈstɔrɪdʒ] | n. 存储 |
populate | [ˈpɑ:pjuleɪt] | v. 填充 |
throw away | 丢弃 | |
auto-configure | 自动配置 | |
connection | [kəˈnɛkʃən] | n. 连接 |
build dependency | 编译依赖 | |
ensure | [ɛnˈʃʊr] | v. 确保 |
automatic | [ˌɔtəˈmætɪk] | adj. 自动的 |
shutdown | [ˈʃʌtˌdaʊn] | n. 关闭,关机 |
disabled | [dɪsˈebəld] | adj. 残疾的;有缺陷的;禁用的 |
thereby | [ˌðerˈbaɪ] | adv. 由此,从而 |
access | [ˈæksɛs] | n. 进入 |