- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试结合使用eclipselink(2.4.0)和spring-data-jpa(1.1.0.RELEASE)来实现一个解决方案。但是,每次部署解决方案(Tomcat 7)时,都会出现以下异常:
Caused by: java.lang.IllegalArgumentException: No [ManagedType] was found for
the key class [com.acme.domain.entities.User] in the Metamodel - please
verify that the [Managed] class was referenced in persistence.xml using a
specific <class>com.acme.domain.entities.User</class> property or a global
<exclude-unlisted-classes>false</exclude-unlisted-classes> element.
@Component
public class UserDataService {
@Autowired
private UserRepository userRepository;
...
}
package com.acme.domain.entities;
...
@Entity
@Table(name = "users")
public class User implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "user_id")
private Integer id;
...
}
<persistence-unit name="default" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>com.acme.domain.entities.User</class>
...
</persistence-unit>
[#|2012-07-31 16:25:02,317|ERROR|pool-2-thread-40|org.springframework.web.context.ContextLoader|Context initialization failed|#]
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDataService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.acme.data.repositories.UserRepository com.acme.data.services.UserDataService.userRepository; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userRepository': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalArgumentException: No [ManagedType] was found for the key class [com.acme.domain.entities.User] in the Metamodel - please verify that the [Managed] class was referenced in persistence.xml using a specific <class>com.acme.domain.entities.User</class> property or a global <exclude-unlisted-classes>false</exclude-unlisted-classes> element.
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:287)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1106)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:609)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:469)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:383)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4779)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5273)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:897)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:873)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:615)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:958)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1599)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:680)
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.acme.data.repositories.UserRepository com.acme.data.services.UserDataService.userRepository; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userRepository': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalArgumentException: No [ManagedType] was found for the key class [com.acme.domain.entities.User] in the Metamodel - please verify that the [Managed] class was referenced in persistence.xml using a specific <class>com.acme.domain.entities.User</class> property or a global <exclude-unlisted-classes>false</exclude-unlisted-classes> element.
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:512)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:92)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:284)
... 27 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userRepository': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalArgumentException: No [ManagedType] was found for the key class [com.acme.domain.entities.User] in the Metamodel - please verify that the [Managed] class was referenced in persistence.xml using a specific <class>com.acme.domain.entities.User</class> property or a global <exclude-unlisted-classes>false</exclude-unlisted-classes> element.
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:1442)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:305)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:876)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:818)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:735)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:484)
... 29 more
Caused by: java.lang.IllegalArgumentException: No [ManagedType] was found for the key class [com.acme.domain.entities.User] in the Metamodel - please verify that the [Managed] class was referenced in persistence.xml using a specific <class>com.acme.domain.entities.User</class> property or a global <exclude-unlisted-classes>false</exclude-unlisted-classes> element.
at org.eclipse.persistence.internal.jpa.metamodel.MetamodelImpl.entityEmbeddableManagedTypeNotFound(MetamodelImpl.java:174)
at org.eclipse.persistence.internal.jpa.metamodel.MetamodelImpl.managedType(MetamodelImpl.java:489)
at org.springframework.data.jpa.repository.support.JpaMetamodelEntityInformation.<init>(JpaMetamodelEntityInformation.java:58)
at org.springframework.data.jpa.repository.support.JpaEntityInformationSupport.getMetadata(JpaEntityInformationSupport.java:65)
at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getEntityInformation(JpaRepositoryFactory.java:149)
at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:87)
at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:70)
at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:137)
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.getObject(RepositoryFactoryBeanSupport.java:125)
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.getObject(RepositoryFactoryBeanSupport.java:41)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:142)
... 37 more
最佳答案
我能够解决我的问题,但这是上面的另一种设置,我只添加了偶然发现的几件事,直到能够在我的SE环境中解决它:
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<bean id="customEntityManagerFactory" parent="abstractEntityManagerFactory">
<property name="dataSource" ref="dataSource"/>
<!-- Packages of EntityClasses -->
<property name="packagesToScan">
<list merge="true">
<value>ch.company.div1.foo.bar.model</value>
<value>ch.company.div1.foo.barnicle.model</value>
<value>ch.company.div2.we.help.model</value>
</list>
</property>
<property name="jpaProperties">
<props merge="true">
<prop key="eclipselink.target-database">org.eclipse.persistence.platform.database.SQLServerPlatform
</prop>
<prop key="javax.persistence.transactionType">RESOURCE_LOCAL</prop>
</props>
</property>
</bean>
关于Eclipselink和Spring数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11723208/
我主要根据 EclipseLink 网站上的教程编写了以下代码: Partner p = new Partner(); p.setId(1); p.setKey("a");
我主要根据 EclipseLink 网站上的教程编写了以下代码: Partner p = new Partner(); p.setId(1); p.setKey("a");
我目前尝试在 WebLogic Server 12c 中运行 Docx4j。 WebLogic Server 12c 随 EclipseLink 2.3.2 一起提供。 有一个类似的Post描述不幸的
例如,在 EclipseLink 中使用 @AdditionalCriteria 很容易过滤掉软删除的实体,但是有什么方法可以在执行特定查询之前暂时禁用它? 最佳答案 是的,这是可能的,有一个简单的解
我们正在考虑从 Oracle Kodo JDO 迁移到 TopLink 11g JPA。但我发现 EclipseLink 确实存在,而且似乎更应该感谢 Toplink。目前关于它的维基文章指出 Ecl
我正在使用 h2 为使用 Eclipselink、Arquillian 和 Weblogic 12.1.1 的应用程序设置集成测试 这是我的实体: @Entity @Table(name = "AFI
我正在创建一个简单的应用程序,我将在其中使用对象关系映射。我听说过 eclipselink JPA 并做了一个 POC。看起来就像在我本地工作。 我脑子里有两个问题。 eclipselink 与环境有
加载有什么区别: 对比 我可以看到在 maven“EclipseLink”中命名的 Eclipselink 比另一个有更多的类和实用程序......例如目标数据库: org.eclipse.per
我的目标是学习 JavaEE,还有什么比参与项目更好的方法呢?因此,我开始创建一个股票市场模拟 Web 应用程序。当然,一个人拥有一些由公司代码 (company_id) 标识的股票以及所拥有的相关股
Bundle org.eclipse.persistence.extension_2.7.0.qualifier.jar(我安装到 osgi 框架)包含类 org.eclipse.persistenc
我正在尝试向我的 Spring 数据 jpa 存储库添加 Multi-Tenancy 支持。我想为每个请求动态设置租户 ID,但它不适用于自定义查找器 查找* 存储库上的方法。 我已遵循此指南:htt
我使用 Spring Data JPA 和 EclipseLink 2.5.2 作为我的 JPA 提供程序。我使用的数据库是 PostgreSQL。我有一个具有自动递增序列号的表,如下所示: CREA
我无法在单元测试中找到 ecbDB JTA 数据源。 对于 RESOURCE_LOCAL,相同的 persistence.xml 工作。只有在 EJB 容器内,它才无法定位 JTA 数据源。 执行单元
我收到一条错误消息: 异常[EclipseLink-6004] ...对象bla不是来自这个UnitOfWork对象空间,而是来自父 session 的对象空间。该对象从未在此UnitOfWork中注
在将我的 jpa 项目部署到 Wildfly 服务器时,我收到以下警告: The collection of metamodel types is empty. Model classes may n
我定义了一些实体,现在想生成表。 我使用Eclipselink 2.5(JPA 2.1)和Glassfish 4.0,我的程序使用JKD7。 当我构建应用程序时,会显示以下消息: warning: S
我使用的是最新的 EclipseLink 版本和 MySQL 5.5(表类型 InnoDB)。我一次插入大约 30900 条记录(也可能更多)。问题是,插入性能很差:插入所有记录大约需要 22 秒(与
我在持久化实体并在持久化发生后获取 id 时遇到了问题。我可以看到数据是在数据库中创建的,具有正确的 id,但对象处的 id 仍然为 null。 这是我的实体: @Entity public clas
我使用 eclipselink 2.6.3,我需要确切地知道连接池是否由 Eclipselink 创建和使用。 如果persistence.xml我有如下设置 但是,这两种情况的日志是相同的
我正在使用 EclipseLink,并将“eclipselink.ddl-generation”属性设置为“create-tables”。创建的表中列的顺序似乎是随机的。我想要特定顺序的列 - 字段在
我是一名优秀的程序员,十分优秀!