My'name.is Fei jianfeihuacha...

hello!my name is wang fei. i do not have any fun_百度知道
hello!my name is wang fei. i do not have any fun
because there are too 1
我有更好的答案
按默认排序
I don&#39。我没有如何乐趣Hello!我的名字叫王菲!t have any fun你好
其他类似问题
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁课件unit1 My name is Gina 最新人教版_百度文库
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
文档贡献者
评价文档:
喜欢此文档的还喜欢
课件unit1 My name is Gina 最新人教版
整​单​元​的​课​件
把文档贴到Blog、BBS或个人站等:
普通尺寸(450*500pix)
较大尺寸(630*500pix)
大小:11.77MB
登录百度文库,专享文档复制特权,财富值每天免费拿!
你可能喜欢my name is lin fei.下一句对话是什么_百度作业帮
拍照搜题,秒出答案
my name is lin fei.下一句对话是什么
my name is lin fei.下一句对话是什么
What's your name?
Nice to meet youStack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.
I have created spring data JPA sample project. I used eclips for this. There are two projects, one is domain object project which has only annotated entity classes.
Other project is actual spring data jpa project and it has a dependency for the project one. Actually it gets domain project entity classes via maven dependency.
Project 1 : hrm-domain
Entity class :
package com.hrm.ws.data.
import javax.persistence.B
import javax.persistence.C
import javax.persistence.E
import javax.persistence.GeneratedV
import javax.persistence.GenerationT
import javax.persistence.Id;
import javax.persistence.I
import javax.persistence.InheritanceT
import javax.persistence.T
@Entity(name = "Employee")
@Table(name = "employee")
@Inheritance(strategy = InheritanceType.JOINED)
public class Employee {
protected String firstN
protected String lastN
* Gets the value of the id property.
@Column(name = "id", scale = 0)
@GeneratedValue(strategy = GenerationType.AUTO)
public long getId() {
Project 2 : hrm-ws-service
persistance-context.xml
&?xml version="1.0" encoding="UTF-8"?&
&beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/data/jpa
http://www.springframework.org/schema/data/jpa/spring-jpa.xsd"&
&bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"&
&property name="driverClassName" value="${jdbc.driverClassName}"/&
&property name="url" value="${jdbc.url}"/&
&property name="username" value="${jdbc.username}"/&
&property name="password" value="${jdbc.password}"/&
&jpa:repositories base-package="com.hrm.ws.data.repository" /&
&bean id="employeeDao" class="com.hrm.ws.data.repository.EmployeeRepositoryImpl"/&
&bean class="org.springframework.orm.jpa.JpaTransactionManager" id="transactionManager"&
&property name="entityManagerFactory" ref="entityManagerFactory" /&
&property name="jpaDialect"&
&bean class="org.springframework.orm.jpa.vendor.HibernateJpaDialect" /&
&/property&
&bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"&
&property name="dataSource" ref="dataSource" /&
&property name="jpaVendorAdapter"&
&bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"&
&property name="generateDdl" value="${jdbc.generateDdl}" /&
&property name="showSql" value="${jdbc.showSql}"/&
&/property&
&property name="persistenceUnitName" value="jpa.sample" /&
So the setup for my packages is as follows:
src/main/java - contains the spring repository
src/main/resources - contains application context
src/test/java - contains unit tests
And dependency for the project 1 (hrm-domain)
My problem is when I run this project I am getting error as follows:
... 38 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'employeeRepository': FactoryBean threw exceptio nested exception is java.lang.IllegalArgumentException: Not an entity: class com.hrm.ws.data.domain.Employee
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:149)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:102)
at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1429)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:844)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:786)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:703)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:474)
... 40 more
**Caused by: java.lang.IllegalArgumentException: Not an entity: class** com.hrm.ws.data.domain.Employee
at org.hibernate.ejb.metamodel.MetamodelImpl.entity(MetamodelImpl.java:160)
at org.springframework.data.jpa.repository.support.JpaMetamodelEntityInformation.&init&(JpaMetamodelEntityInformation.java:52)
at org.springframework.data.jpa.repository.support.JpaEntityInformationSupport.getMetadata(JpaEntityInformationSupport.java:61)
at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getEntityInformation(JpaRepositoryFactory.java:145)
at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:83)
at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:66)
at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:146)
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.getObject(RepositoryFactoryBeanSupport.java:120)
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.getObject(RepositoryFactoryBeanSupport.java:39)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:142)
... 48 more
I am wondering about this issue, because when I put domain object (Employee.java)
in my spring project it self rather separate jar it works fine. This issue only happens it gives as a separate jar.
If any one has experience about
scenario like that please give me a help.
162k13337411
I also had the same problem. Mine was that I didn't supply the packagesToScan property in the entityManagerFactory bean, so Spring couldn't load the Entities. Check out the emf bean declaration in your spring configuration xml. The following is a EMF declaration I hope it could help you to get rid the error:
&bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"&
&property name="dataSource" ref="dataSource" /&
&property name="jpaVendorAdapter"&
&bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" /&
&/property&
&property name="packagesToScan" value="com.hrm.ws.data.domain" /&
&property name="jpaDialect"&
&bean class="org.springframework.orm.jpa.vendor.HibernateJpaDialect" /&
&/property&
9,69731729
You're not scanning the com.hrm.ws.data.domain package for beans annotated with @Entity so the spring container has no knowledge of your entities and therefore producing an exception. Add the following lines to your persistance-context.xml config file:
&context:annotation-config /&
&context:component-scan base-package="com.hrm.ws.data.domain" /&
You'll also need to change your root xml element as follows so it the context elements are recognized:
&beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/data/jpa
http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd"&
And, if you haven't already, add the spring-context dependency to your pom file.
Use one of the following option :-
context:component-scan
base-package="Your Base Package Name" in spring.xml file
set packagesToScan property on the entityManagerFactory
use persistence.xml and list all entities there.
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Sign up using Stack Exchange
Post as a guest
Post as a guest
By posting your answer, you agree to the
Not the answer you're looking for?
Browse other questions tagged
Top questions and answers
Important announcements
Unanswered questions
By subscribing, you agree to the
Stack Overflow works best with JavaScript enabled

我要回帖

更多关于 jianfeihuacha 的文章

 

随机推荐