spring.jpa.hibernate.naming-strategy
时间: 2023-12-18 12:02:09 浏览: 41
这是一个配置项,用于指定 Hibernate 在生成数据库表和列名时使用的命名策略。它可以设置为一个实现了 org.hibernate.boot.model.naming.PhysicalNamingStrategy 接口的类的全限定名。该接口定义了 Hibernate 如何将 Java 实体的属性名转换为数据库表和列的命名。例如,如果设置为 org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl,则 Hibernate 会将属性名转换为下划线分隔的小写字母字符串,如将一个名为 firstName 的属性转换为 first_name 列名。
相关问题
application.properties注释
在Spring Boot应用程序的application.properties文件中,可以设置各种属性来配置应用程序的行为。以下是一些常见的注释,以帮助理解这些属性的作用。
# 数据源配置
spring.datasource.url= # 数据库连接URL
spring.datasource.username= # 数据库用户名
spring.datasource.password= # 数据库密码
spring.datasource.driver-class-name= # 数据库驱动类名
# JPA配置
spring.jpa.show-sql= # 是否显示SQL语句
spring.jpa.hibernate.ddl-auto= # 是否自动创建表
spring.jpa.hibernate.naming.physical-strategy= # 表名、字段名的命名策略
# 日志配置
logging.level.root= # 根日志级别
logging.level.org.springframework= # Spring框架日志级别
logging.level.com.example= # 应用程序包日志级别
# 端口配置
server.port= # 应用程序监听的端口号
# 静态资源配置
spring.resources.static-locations= # 静态资源文件路径
# 缓存配置
spring.cache.type= # 缓存类型
spring.cache.redis.host= # Redis主机名
spring.cache.redis.port= # Redis端口号
spring.cache.redis.password= # Redis密码
# 安全配置
spring.security.user.name= # 默认用户名
spring.security.user.password= # 默认密码
以上注释是一些常见的属性配置,在实际开发中可能会有更多的配置项。在使用时,可以参考注释来了解属性的作用和取值范围。
springboot中使用自己版本的hibernate
在Spring Boot中,可以通过添加以下依赖来使用自己版本的Hibernate:
```xml
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>${your.hibernate.version}</version>
</dependency>
```
其中`${your.hibernate.version}`是你想使用的Hibernate版本号。
然后,在`application.properties`或`application.yml`中配置Hibernate相关的属性,例如:
```properties
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
spring.jpa.hibernate.ddl-auto = update
```
其中`spring.jpa.properties.hibernate.dialect`指定了要使用的Hibernate方言,`spring.jpa.hibernate.ddl-auto`指定了Hibernate的DDL操作方式。
需要注意的是,如果你使用了Spring Data JPA,那么它依赖于Hibernate,因此你也可以通过指定`spring.jpa.hibernate.naming.physical-strategy`属性来使用自定义的物理命名策略。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)