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