精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2012-04-20
string2020 写道 一:
用spring的jdbc模板,直接执行sql 二: 用ibatis 我们公司的sql语句,最少都是10张表关联,请问,用jpa,还不配死人啊。 10张表关联是设计的失败,怎么还拿出否认jpa? |
|
返回顶楼 | |
发表时间:2012-08-05
你好!我按照你讲的把项目搭建起来了,但是测试的是后出错。然后我下载了你提供的源码后,运行测试用例的时候还是出错,错误如下:
[19:24:07-INFO]@TestExecutionListeners is not present for class [class test.com.strong.StringOpenJPATest]: using defaults. [19:24:08-INFO]Loading XML bean definitions from class path resource [applicationContext.xml] [19:24:08-INFO]Refreshing org.springframework.context.support.GenericApplicationContext@df503: startup date [Sun Aug 05 19:24:08 CST 2012]; root of context hierarchy [19:24:08-INFO]Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@2acc65: defining beans [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 [19:24:08-INFO]Building JPA container EntityManagerFactory for persistence unit 'StrongOpenJPAPU' [19:24:08-INFO]Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@2acc65: defining beans [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 [19:24:08-ERROR]Caught exception while allowing TestExecutionListener [org.springframework.test.context.support.DependencyInjectionTestExecutionListener@da18ac] to prepare test instance [test.com.strong.StringOpenJPATest@8a0544] java.lang.IllegalStateException: Failed to load ApplicationContext at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:157) at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:109) 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:47) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71) at org.junit.runners.ParentRunner.run(ParentRunner.java:300) 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.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/apache/commons/lang/exception/NestableRuntimeException at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519) 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:567) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464) at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:103) at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:1) at org.springframework.test.context.support.DelegatingSmartContextLoader.loadContext(DelegatingSmartContextLoader.java:228) at org.springframework.test.context.TestContext.loadApplicationContext(TestContext.java:124) at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:148) ... 24 more Caused by: java.lang.NoClassDefFoundError: org/apache/commons/lang/exception/NestableRuntimeException at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClassCond(Unknown Source) at java.lang.ClassLoader.defineClass(Unknown Source) at java.security.SecureClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.access$000(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at org.apache.openjpa.persistence.PersistenceProviderImpl.createContainerEntityManagerFactory(PersistenceProviderImpl.java:163) at org.apache.openjpa.persistence.PersistenceProviderImpl.createContainerEntityManagerFactory(PersistenceProviderImpl.java:66) at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:268) at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:310) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452) ... 38 more Caused by: java.lang.ClassNotFoundException: org.apache.commons.lang.exception.NestableRuntimeException at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) ... 56 more 这个怎么解决呢?谢谢! |
|
返回顶楼 | |
发表时间:2012-08-05
wenpde163 写道 你好!我按照你讲的把项目搭建起来了,但是测试的是后出错。然后我下载了你提供的源码后,运行测试用例的时候还是出错,错误如下:
首先以后请不要直接贴这么长的错误代码,如果非常必需,可以贴到code里面去,非常影响月的。 刚才看了一下,主要的错误应该就是这个,意思是找不到spring的配置文件,我的项目里面默认是放在src目录下的,运行的时候默认是在builder目录下,你检查一下配置文件是否在。 java.lang.IllegalStateException: Failed to load ApplicationContext 另外,Caused by: java.lang.NoClassDefFoundError: org/apache/commons/lang/exception/NestableRuntimeException 这个错误不太清楚,不知道是不是maven没有把jar包拉下来 |
|
返回顶楼 | |
发表时间:2012-08-05
simen_net 写道 wenpde163 写道 你好!我按照你讲的把项目搭建起来了,但是测试的是后出错。然后我下载了你提供的源码后,运行测试用例的时候还是出错,错误如下:
首先以后请不要直接贴这么长的错误代码,如果非常必需,可以贴到code里面去,非常影响月的。 刚才看了一下,主要的错误应该就是这个,意思是找不到spring的配置文件,我的项目里面默认是放在src目录下的,运行的时候默认是在builder目录下,你检查一下配置文件是否在。 java.lang.IllegalStateException: Failed to load ApplicationContext 另外,Caused by: java.lang.NoClassDefFoundError: org/apache/commons/lang/exception/NestableRuntimeException 这个错误不太清楚,不知道是不是maven没有把jar包拉下来 好久没见你出来了 |
|
返回顶楼 | |
发表时间:2012-08-06
还是SQL写着顺手,不会优化JPA,hibernate,到现在还不知道怎么配置二级缓存,也不知道怎么解决N+1问题
|
|
返回顶楼 | |
发表时间:2012-08-06
对会这些高深技术的人很是膜拜
|
|
返回顶楼 | |
发表时间:2012-09-14
初学OpenJPA,非常谢谢技术大拿的分享, 我会好好学习的! |
|
返回顶楼 | |
发表时间:2012-10-09
我就不跟你学。
|
|
返回顶楼 | |
发表时间:2012-10-10
Technoboy 写道 string2020 写道 一:
用spring的jdbc模板,直接执行sql 二: 用ibatis 我们公司的sql语句,最少都是10张表关联,请问,用jpa,还不配死人啊。 10张表关联是设计的失败,怎么还拿出否认jpa? 你的思路有问题,不是JPA有问题。 即便100张表关联,也和JPA没有关系,你们思路出问题了。 |
|
返回顶楼 | |
发表时间:2012-10-10
一小区十户人家九户都装了防盗门,只有一户没装,一天九户人家一起被窃,唯有没装防盗门的这户门上小偷写道:你放心我,我也放心你!
|
|
返回顶楼 | |