我正在尝试更改使用内存 HSQL 数据库的默认LightAdmin设置以使用文件 HSQL 数据库。
持久性.xml:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" 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">
<persistence-unit name="DEMO" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>org.lightadmin.demo.model.Address</class>
<class>org.lightadmin.demo.model.Customer</class>
<class>org.lightadmin.demo.model.EmailAddress</class>
<class>org.lightadmin.demo.model.Product</class>
<class>org.lightadmin.demo.model.Order</class>
<class>org.lightadmin.demo.model.LineItem</class>
<class>org.lightadmin.demo.model.DiscountProgram</class>
</persistence-unit>
</persistence>
弹簧上下文.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:p="http://www.springframework.org/schema/p"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<context:component-scan base-package="org.lightadmin.demo.service"/>
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
p:persistenceUnitName="DEMO" p:dataSource-ref="dataSource">
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="generateDdl" value="true"/>
<property name="database" value="HSQL"/>
</bean>
</property>
</bean>
<jdbc:embedded-database id="dataSource" type="HSQL">
<jdbc:script location="classpath:db/schema.sql" encoding="UTF-8"/>
<jdbc:script location="classpath:db/data.sql" encoding="UTF-8"/>
</jdbc:embedded-database>
</beans>
我尝试过的:在 persistence.xml 中提供了以下属性:
<property name="hibernate.connection.url" value="jdbc:hsqldb:file:database"/>
<property name="hibernate.hbm2ddl.auto" value="update" />
但它没有完成它的工作。