1
回答
java.lang.UnsupportedOperationException: The user must supply a JDBC connection
利用AWS快速构建适用于生产的无服务器应用程序,免费试用12个月>>>   

配置jpa,老是有错,烦人,感觉是没有连上数据库?不应该啊



下面上配置文件persistence.xml文件内容如下

 

<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
version="2.0">
<persistence-unit name="SimplePU" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<properties>
<property name="hibernate.connection.driver_class" value="org.h2.Driver" />
<property name="hibernate.connection.url" value="jdbc:h2:tcp://localhost/~/test" />
<property name="hibernate.connection.username" value="sa" />
<property name="hibernate.connection.password" value="" />
<property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect" />
<property name="hibernate.show_sql" value="false" />
<property name="hibernate.format_sql" value="true" />
<property name="hibernate.use_sql_comments" value="false" />
<property name="hibernate.hbm2ddl.auto" value="update" />
</properties>
</persistence-unit>
</persistence>

下面是启动时的servlet-context.xml


<tx:annotation-driven transaction-manager="transactionManager" />
	<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
		<property name="entityManagerFactory" ref="entityManagerFactory" />
	</bean>
	<bean id="entityManagerFactory"
		class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
		<property name="persistenceUnitName" value="SimplePU"/>
	</bean>
	<jpa:repositories base-package="gemlite.core.webapp.jpa"
		entity-manager-factory-ref="entityManagerFactory"
		transaction-manager-ref="transactionManager" repository-impl-postfix="Impl">
	</jpa:repositories>




举报
顶部