精华帖 (0) :: 良好帖 (1) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2012-06-06
mappedBy = "aEntity" 应该是这样吧, 然后你persist b试试
|
|
返回顶楼 | |
发表时间:2012-12-15
给看看这个错误是因为啥。
----------------------------------------------------------- [17:51:18-INFO]@TestExecutionListeners is not present for class [class test.com.jpa.model.StringOpenJPATest]: using defaults. [17:51:18-INFO]Loading XML bean definitions from class path resource [applicationContext.xml] [17:51:19-INFO]Refreshing org.springframework.context.support.GenericApplicationContext@166afb3: startup date [Sat Dec 15 17:51:19 CST 2012]; root of context hierarchy [17:51:19-INFO]Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@1ba94d: defining beans [systemUserDAOImpl,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,entityManagerFactory,transactionManager,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0,org.springframework.transaction.interceptor.TransactionInterceptor#0,org.springframework.transaction.config.internalTransactionAdvisor,org.springframework.context.annotation.ConfigurationClassPostProcessor$ImportAwareBeanPostProcessor#0]; root of factory hierarchy [17:51:19-INFO]Building JPA container EntityManagerFactory for persistence unit 'OpenJPA' 10 OpenJPA WARN [main] openjpa.Runtime - The configuration property named "openjpa.ClassLoadEnhancement" was not recognized and will be ignored, although the name closely matches a valid property called "openjpa.PostLoadOnMerge". 0 OpenJPA WARN [main] openjpa.Runtime - The configuration property named "openjpa.ClassLoadEnhancement" was not recognized and will be ignored, although the name closely matches a valid property called "openjpa.PostLoadOnMerge". 20 OpenJPA WARN [main] openjpa.Runtime - An error occurred while registering a ClassTransformer with PersistenceUnitInfo: name 'OpenJPA', root URL [file:/D:/workspace/OpenJPA/target/classes/]. The error has been consumed. To see it, set your openjpa.Runtime log level to TRACE. Load-time class transformation will not be available. [17:51:19-ERROR]Caught exception while allowing TestExecutionListener [org.springframework.test.context.support.DependencyInjectionTestExecutionListener@5bf624] to prepare test instance [test.com.jpa.model.StringOpenJPATest@17cd15d] org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'test.com.jpa.model.StringOpenJPATest': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.jpa.service.SystemUserService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@javax.annotation.Resource(shareable=true, mappedName=, description=, name=, type=class java.lang.Object, authenticationType=CONTAINER)} at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:306) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1106) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireBeanProperties(AbstractAutowireCapableBeanFactory.java:374) at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:110) at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:75) at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:321) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:211) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:288) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:290) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:46) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41) at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71) at org.junit.runners.ParentRunner.run(ParentRunner.java:220) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.jpa.service.SystemUserService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@javax.annotation.Resource(shareable=true, mappedName=, description=, name=, type=class java.lang.Object, authenticationType=CONTAINER)} at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:924) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:793) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:707) at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:438) at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:416) at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:549) at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:150) at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87) at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:303) ... 26 more [17:51:19-INFO]Closing org.springframework.context.support.GenericApplicationContext@166afb3: startup date [Sat Dec 15 17:51:19 CST 2012]; root of context hierarchy [17:51:19-INFO]Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@1ba94d: defining beans [systemUserDAOImpl,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,entityManagerFactory,transactionManager,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0,org.springframework.transaction.interceptor.TransactionInterceptor#0,org.springframework.transaction.config.internalTransactionAdvisor,org.springframework.context.annotation.ConfigurationClassPostProcessor$ImportAwareBeanPostProcessor#0]; root of factory hierarchy [17:51:19-INFO]Closing JPA EntityManagerFactory for persistence unit 'OpenJPA' |
|
返回顶楼 | |
发表时间:2012-12-15
这个异常代码不全吧
|
|
返回顶楼 | |
发表时间:2012-12-15
No matching bean of type [com.jpa.service.SystemUserService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@javax.annotation.Resource(shareable=true, mappedName=, description=, name=, type=class java.lang.Object, authenticationType=CONTAINER)}
at 没有找到com.jpa.service.SystemUserService 可能的原因: 1、你使用动态代理了?且是接口代理,而SystemUserService是一个具体的类,所以注入不匹配 |
|
返回顶楼 | |
发表时间:2012-12-15
最后修改:2012-12-15
jinnianshilongnian 写道 No matching bean of type [com.jpa.service.SystemUserService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@javax.annotation.Resource(shareable=true, mappedName=, description=, name=, type=class java.lang.Object, authenticationType=CONTAINER)}
at 没有找到com.jpa.service.SystemUserService 可能的原因: 1、你使用动态代理了?且是接口代理,而SystemUserService是一个具体的类,所以注入不匹配 我照着楼主的代码写的。是不是那个配置错了? SystemUserService 这是个接口。 @Transactional public interface SystemUserService { public void doShiWuTianJia(SystemUser systemUser); /** * 直接执行SQL清空记录 */ public void doQingKong(); } |
|
返回顶楼 | |
发表时间:2012-12-15
simen_net 写道 这个异常代码不全吧
是全部异常错误,照着你的代码写的。 有些代码没按你的位置放。 |
|
返回顶楼 | |
发表时间:2012-12-15
fenyun689 写道 jinnianshilongnian 写道 No matching bean of type [com.jpa.service.SystemUserService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@javax.annotation.Resource(shareable=true, mappedName=, description=, name=, type=class java.lang.Object, authenticationType=CONTAINER)}
at 没有找到com.jpa.service.SystemUserService 可能的原因: 1、你使用动态代理了?且是接口代理,而SystemUserService是一个具体的类,所以注入不匹配 我照着楼主的代码写的。是不是那个配置错了? SystemUserService 这是个接口。 @Transactional public interface SystemUserService { public void doShiWuTianJia(SystemUser systemUser); /** * 直接执行SQL清空记录 */ public void doQingKong(); } 你的实现注册了吗? |
|
返回顶楼 | |
发表时间:2012-12-15
不知道咋注册?
|
|
返回顶楼 | |
发表时间:2012-12-15
引用 你的实现注册了吗? 咋看是否注册了? |
|
返回顶楼 | |
发表时间:2012-12-15
fenyun689 写道 引用 你的实现注册了吗? 咋看是否注册了? 比如实现通过@Service注册啊 |
|
返回顶楼 | |