栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

javax.persistence.PersistenceException:没有名为enterManager的EntityManager的持久性提供程序

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

javax.persistence.PersistenceException:没有名为enterManager的EntityManager的持久性提供程序

persistence.xml
的用户名无效,
EntityManagerFactory
因此无法创建。它应该是:

<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_1_0.xsd" version="1.0">  <persistence-unit name="customerManager" transaction-type="RESOURCE_LOCAL">    <provider>org.hibernate.ejb.HibernatePersistence</provider>    <class>Customer</class>    <properties>      <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLInnoDBDialect"/>      <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>      <property name="hibernate.show_sql" value="true"/>      <property name="hibernate.connection.username" value="root"/>      <property name="hibernate.connection.password" value="1234"/>      <property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/general"/>      <property name="hibernate.max_fetch_depth" value="3"/>    </properties>  </persistence-unit></persistence>

(请注意

<property>
元素是如何关闭的,不应嵌套)

更新:
我遍历了本教程,

Id
使用MySQL时,您还必须更改生成策略(因为MySQL不支持序列)。我建议使用该
AUTO
策略(MySQL默认为IDENTITY)。为此,请删除
SequenceGenerator
注释并按如下所示更改代码:

@Entity@Table(name="TAB_CUSTOMER")public class Customer implements Serializable {    private static final long serialVersionUID = 1L;    @Id    @GeneratedValue(strategy=GenerationType.AUTO)    @Column(name="CUSTOMER_ID", precision=0)    private Long customerId = null;   ...}

这应该有所帮助。

PS:您还应该提供一个

log4j.properties
建议。



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/568899.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号