【spring boot】配置文件 application.properties 属性解析

1.JPA命名策略

spring.jpa.hibernate.naming-strategy = org.hibernate.cfg.DefaultNamingStrategy

有两种值可以配置分别为:

第一:org.hibernate.cfg.DefaultNamingStrategy 
第二:org.hibernate.cfg.ImprovedNamingStrategy  
DefaultNamingStrategy这个直接映射,不会做过多的处理(前提没有设置@Table,@Column等属性的时候)。如果有@Column则以@Column为准
ImprovedNamingStrategy 表名,字段为小写,当有大写字母的时候会转换为分隔符号“_”。  

参考地址:http://blog.csdn.net/linxingliang/article/details/52566896

2.hibernate的DDL执行策略

spring.jpa.hibernate.ddl-auto=update

有下面5种值可以配置

①create

如果设置为该值,则每次加载hibernate时(准确说应是创建SessionFactory时)都会删除以前创建的表而根据model重新生成表,即使前后的表没有任何变化,通常会造成数据库数据丢失,需谨慎使用这个取值

②create-drop

与create差不多,所不同的是每次sessionFactory关闭时,就会删除所有表

③update

这个取值比较常用,需要先建立数据库,在第一次加载hibernate时会自动创建表,以后创建hibernate会自动根据model更新表结构,即使表结构改变了,以前的行不会被删除

④validate

每次加载hibernate时,验证创建数据库表结构,只会和数据库中的表进行比较,不会创建新表,但是会插入新值

3.初始化数据库时发生错误,不要停止

spring.datasource.continue-on-error=false 

默认值是false

4.

时间: 2024-08-02 20:59:59

【spring boot】配置文件 application.properties 属性解析的相关文章

Spring Boot2 系列教程(四)理解Spring Boot 配置文件 application.properties

在 Spring Boot 中,配置文件有两种不同的格式,一个是 properties ,另一个是 yaml . 虽然 properties 文件比较常见,但是相对于 properties 而言,yaml 更加简洁明了,而且使用的场景也更多,很多开源项目都是使用 yaml 进行配置(例如 Hexo).除了简洁,yaml 还有另外一个特点,就是 yaml 中的数据是有序的,properties 中的数据是无序的,在一些需要路径匹配的配置中,顺序就显得尤为重要(例如我们在 Spring Cloud

Spring boot配置文件application.properties

# =================================================================== # COMMON SPRING BOOT PROPERTIES # # This sample file is provided as a guideline. Do NOT copy it in its # entirety to your own application.               ^^^ # =====================

Spring boot配置文件 application.properties

# =================================================================== # COMMON SPRING BOOT PROPERTIES # # This sample file is provided as a guideline. Do NOT copy it in its # entirety to your own application.               ^^^ # =====================

附录 B. Spring Boot 配置文件 application.properties

#########COMMON SPRING BOOT PROPERTIES ######========CORE PROPERTIES=========== #SPRING CONFIG (ConfigFileApplicationListener) spring.config.name= # config file name (default to 'application') spring.config.location= # location of config file #PROFIL

Spring Boot 配置文件application.properties

#########COMMON SPRING BOOT PROPERTIES ######========CORE PROPERTIES=========== #SPRING CONFIG (ConfigFileApplicationListener) spring.config.name= # config file name (default to 'application') spring.config.location= # location of config file #PROFIL

spring boot配置文件application.properties配置JPA以及数据源

1.application.properties配置jpa模板 spring.datasource.url=jdbc:mysql://localhost:3306/springboottest?useUnicode=true&characterEncoding=utf8&serverTimezone=UTC spring.datasource.username=rootspring.datasource.password=Zp970321spring.datasource.driver-c

附录B. Spring Boot 配置文件application.properties

#SPRING CONFIG (ConfigFileApplicationListener) spring.config.name= # config file name (default to 'application') spring.config.location= # location of config file #PROFILES spring.profiles= # comma list of active profiles #APPLICATION SETTINGS (Sprin

spring boot项目application.properties多环境配置文件、jar包外部配置文件

一.简介 spring boot项目application.properties文件存放及使用介绍 二.方法一多环境配置文件 我们一般都会有多个应用环境,开发环境.测试环境.生产环境,各个环境的配置会略有不同,我可以根据这个创建多份配置文件,由主配置文件来控制读取那个子配置 创建spring boot项目后可以同时创建多个.properties文件,只要符合它要求的格式即可 格式:application-{profile}.properties:{profile}是变量用于自定义配置文件名称 分

spring boot 配置文件application

场景:在项目部署的过程中,对于spring boot的配置文件一直不很了解,直到项目出现一个莫名其妙的问题——工程classes中的配置文件被覆盖,程序启动总是报错! 1  配置文件的优先级 application.properties大家都不陌生,我们在开发的时候,经常使用它来配置一些可以手动修改而且不用编译的变量,这样的作用在于,打成war包或者jar用于生产环境时,我们可以手动修改环境变量而不用再重新编译. spring boo默认已经配置了很多环境变量,例如,tomcat的默认端口是80