persistence.xml
里面需要配置关于Hibernate的信息
以后需要的配置属性都可以在此文件里面找到
<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">
<persistence-unit name="cn.itsource.jpa" transaction-type="RESOURCE_LOCAL">
<properties>
<!-- 必须配置4个连接数据库属性 -->
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver" />
<property name="hibernate.connection.url" value="jdbc:mysql:///jpa" />
<property name="hibernate.connection.username" value="root" />
<property name="hibernate.connection.password" value="admin" />
<!-- 必须配置1个方言属性 -->
<!-- 实现跨数据库关键类 :查询MySQLDialect的getLimitString方法 -->
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
<!-- 可选配置 -->
<!-- 是否自动生成表 -->
<property name=ql -->
<property name="hibernate.show_sql" value="true" />
<!-- 格式化sql -->
<!-- <property name="hibernate.format_sql" value="true" /> -->
</properties>
</persistence-unit>
</persistence>
IDEA配置persistence.xml
最新推荐文章于 2021-10-27 17:17:16 发布