--》此处使用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>