Spring Boot 整合 Hibernate5
Run
java -jar -Dspring.profiles.active=dev sport.web.services.jar
Maven
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.2.RELEASE</version>
</parent>
SessionFactory
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.orm.jpa.vendor.HibernateJpaSessionFactoryBean; @Configuration
public class JpaSessionConfig { @Bean
public HibernateJpaSessionFactoryBean sessionFactory() {
HibernateJpaSessionFactoryBean sessionFactory=new HibernateJpaSessionFactoryBean();
return sessionFactory;
}
}
bootstrap.yml
spring:
application:
name: sport_native_service
profiles:
active: dev
application-dev.yml
spring:
jpa:
database: MYSQL
# 是否显示HQL
show-sql: false
hibernate:
# Entity与数据库表名对应
naming.physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
properties:
javax:
persistence:
sharedCache:
mode: ENABLE_SELECTIVE
hibernate:
# 数据库方言
dialect: org.hibernate.dialect.MySQL5Dialect
# 是否显示统计信息
generate_statistics: flase
# Hibernate二级缓存和Query缓存
cache:
# 二级缓存
use_second_level_cache: true
# Query 缓存
use_query_cache: true
region:
# 使用Ehcache
factory_class: org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory
# Spring Boot 整合Hibernate
current_session_context_class: org.springframework.orm.hibernate5.SpringSessionContext
# 批处理
jdbc.batch_size: 50
messages:
basename: locale/messages
cache-seconds: 3600
eureka:
instance:
hostname: localhost
client:
registerWithEureka: false
fetchRegistry: false
serviceUrl:
defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
app:
cache:
redis:
host: ham.leadadvancetech.com
port: 6379
limit-validation:
cache:
expire: 7200
# 数据源
datasource:
master:
url: jdbc:mysql://ham.leadadvancetech.com:3306/db_theonex?autoReconnect=true&useSSL=false
username: java
password: theonex666
driverClassName: com.mysql.jdbc.Driver
testWhileIdle: true
validationQuery: SELECT 1
Spring Boot 整合 Hibernate5的更多相关文章
- Spring Boot 整合 Elasticsearch,实现 function score query 权重分查询
摘要: 原创出处 www.bysocket.com 「泥瓦匠BYSocket 」欢迎转载,保留摘要,谢谢! 『 预见未来最好的方式就是亲手创造未来 – <史蒂夫·乔布斯传> 』 运行环境: ...
- spring boot整合jsp的那些坑(spring boot 学习笔记之三)
Spring Boot 整合 Jsp 步骤: 1.新建一个spring boot项目 2.修改pom文件 <dependency> <groupId>or ...
- spring boot 系列之四:spring boot 整合JPA
上一篇我们讲了spring boot 整合JdbcTemplate来进行数据的持久化, 这篇我们来说下怎么通过spring boot 整合JPA来实现数据的持久化. 一.代码实现 修改pom,引入依赖 ...
- Spring Kafka和Spring Boot整合实现消息发送与消费简单案例
本文主要分享下Spring Boot和Spring Kafka如何配置整合,实现发送和接收来自Spring Kafka的消息. 先前我已经分享了Kafka的基本介绍与集群环境搭建方法.关于Kafka的 ...
- Spring Boot整合Mybatis并完成CRUD操作
MyBatis 是一款优秀的持久层框架,被各大互联网公司使用,本文使用Spring Boot整合Mybatis,并完成CRUD操作. 为什么要使用Mybatis?我们需要掌握Mybatis吗? 说的官 ...
- spring boot整合Hadoop
最近需要用spring boot + mybatis整合hadoop,其中也有碰到一些坑,记录下来方便后面的人少走些弯路. 背景呢是因为需要在 web 中上传文件到 hdfs ,所以需要在spring ...
- Spring Boot整合Elasticsearch
Spring Boot整合Elasticsearch Elasticsearch是一个全文搜索引擎,专门用于处理大型数据集.根据描述,自然而然使用它来存储和搜索应用程序日志.与Logstash和K ...
- spring boot 整合 百度ueditor富文本
百度的富文本没有提供Java版本的,只给提供了jsp版本,但是呢spring boot 如果是使用内置tomcat启动的话整合jsp是非常困难得,今天小编给大家带来spring boot整合百度富文本 ...
- spring boot 整合quartz ,job不能注入的问题
在使用spring boot 整合quartz的时候,新建定时任务类,实现job接口,在使用@AutoWire或者@Resource时,运行时出现nullpointException的问题.显然是相关 ...
随机推荐
- Poj 2328 Guessing Game(猜数字游戏)
一.题目大意 两个小盆友玩猜数字游戏,一个小盆友心里想着1~10中的一个数字,另一个小盆友猜.如果猜的数字比实际的大,则告诉他"too high",小则"too low& ...
- 时间倒计时 JS
<div id="keleyi">Christmas Countdown</div> <script type="text/javascri ...
- Python:sample函数
sample(序列a,n) 功能:从序列a中随机抽取n个元素,并将n个元素生以list形式返回. 例: from random import randint, sample date = [randi ...
- libvirt, libvirt-python, libvirtd 关系浅析
libvirt 官方解释: http://libvirt.org/ 见分隔线以下. 我的理解:libvirt 作为一个中间层,封装了对下层虚拟化 hypervisor 的操作方法.也就是说,无论你是 ...
- 自己写的一个多应用程序多目录的Makefile
DIR_INC = ./includeDIR_SRC = ./srcDIR_OBJ = ./objDIR_BIN = ./binINCLUDES = -I${DIR_INC} -I.CC => ...
- Myeclipse如何使用Maven添加jar包
很多新手都不知道如何在maven项目里添加jar包. 以前我还没接触maven的时候下载过一个demo,是maven项目. 我居然是照着他的pom.xml文件一个一个的写!!! 很多人认为理所当然的东 ...
- Oracle中生成UUID
Oracle中生成跨系统的唯一识别符UUID非常方便,比生成序列还简单,直接用sys_guid()就行, 例如select sys_guid() from dual 会产生一个跟MAC地址.生成时间相 ...
- tar 排除某个目录
tar -zcvf tomcat.tar.gz --exclude=tomcat/logs --exclude=tomcat/libs tomcat
- PCLVisualizer可视化类(2)
博客转载自:http://www.pclcn.org/study/shownews.php?lang=cn&id=163 可视化点云颜色特征 所示,点赋予不同的颜色表征其对应的z轴值不同.PC ...
- 软件开发中对MVC的一些理解
接口隔离 通俗一点讲,接口隔离就是当一个类需要继承另一个类时, 如果被继承的类中有继承的类用不到的方法或者属性时,就不要去实现这个继承.如果真的情非得已必须要继承,那么也需要从被继承的类中再提取出一个 ...