play framwork2.X jpa(hibernate)配置

--》此处使用mysql

application.conf文件中的配置

# This is the main configuration file for the application.
# https://www.playframework.com/documentation/latest/ConfigFile


  db.default.driver=com.mysql.jdbc.Driver
  db.default.url="jdbc:mysql://localhost/wxtp?Unicode=true&serverTimezone=UTC&characterEncoding=UTF-8"
  db.default.username="njs"
  db.default.password="112314"

  # Provided for JPA access
  db.default.jndiName=DefaultDS


# Point JPA at our database configuration
jpa.default=defaultPersistenceUnit

# Number of database connections
# See https://github.com/brettwooldridge/HikariCP/wiki/About-Pool-Sizing
# db connections = ((physical_core_count * 2) + effective_spindle_count)
fixedConnectionPool = 9

# Set Hikari to fixed size
play.db {
  prototype {
    hikaricp.minimumIdle = ${fixedConnectionPool}
    hikaricp.maximumPoolSize = ${fixedConnectionPool}
  }
}

# Job queue sized to HikariCP connection pool
database.dispatcher {
  executor = "thread-pool-executor"
  throughput = 1
  thread-pool-executor {
    fixed-pool-size = ${fixedConnectionPool}
  }
}

persisitence.xml配置(该文件放在META-INF下,若没有需要自己创建)

<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"
             version="2.1">

    <persistence-unit name="defaultPersistenceUnit" transaction-type="RESOURCE_LOCAL">
        <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
        <non-jta-data-source>DefaultDS</non-jta-data-source>
        <properties>
                <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect" />
                <property name="hibernate.max_fetch_depth" value="3" />
            <property name="hibernate.hbm2ddl.auto" value="update"/>
        </properties>
    </persistence-unit>

</persistence>



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值