首页 > 代码库 > IllegalArgumentException: Unknown entity
IllegalArgumentException: Unknown entity
需要使用persistence.xml进行配置。
1 <?xml version="1.0" encoding="UTF-8"?> 2 <persistence version="1.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_1_0.xsd"> 3 <persistence-unit name="WebofficeOne" transaction-type="RESOURCE_LOCAL"> 4 <provider>org.hibernate.ejb.HibernatePersistence</provider> 5 <!-- <jta-data-source>dataSource</jta-data-source> --> 6 <class>net.etec.ftm.domain.City</class> 7 <class>net.etec.ftm.domain.Country</class> 8 <exclude-unlisted-classes>false</exclude-unlisted-classes> 9 <properties>10 <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver" />11 <property name="hibernate.show_sql" value="true"/>12 <property name="hibernate.hbm2ddl.auto" value="update"/>13 <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect"/>14 <property name="hibernate.connection.username" value="root"/>15 <property name="hibernate.connection.password" value="801216"/>16 <property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/test?createDatabaseIfNotExist=true"/>17 <property name="hibernate.c3p0.min_size" value="5"/>18 <property name="hibernate.c3p0.max_size" value="20"/>19 <property name="hibernate.c3p0.timeout" value="300"/>20 <property name="hibernate.c3p0.max_statements" value="50"/>21 <property name="hibernate.c3p0.idle_test_period" value="3000"/>22 </properties>23 </persistence-unit>24 </persistence>
实体工厂配置
1 <bean id="entityManagerFactory" 2 class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> 3 <property name="persistenceUnitName" value="WebofficeOne" /> 4 <!-- <property name="dataSource" ref="dataSource" /> --> 5 <property name="jpaVendorAdapter" ref="hibernateJpaVendorAdapter" /> 6 <!-- <property name="packagesToScan" value="http://www.mamicode.com/com.etec.ftm.domain" /> --> 7 <property name="persistenceXmlLocation" value="classpath:META-INF/persistence-instance.xml"/> 8 <property name="jpaProperties"> 9 <props>10 <prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>11 <prop key="hibernate.ejb.naming_strategy">org.hibernate.cfg.ImprovedNamingStrategy</prop>12 <prop key="hibernate.show_sql">true</prop>13 <prop key="hibernate.hbm2ddl.auto">create</prop>14 </props>15 </property>16 </bean>
IllegalArgumentException: Unknown entity
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。