问答详情
源自:5-4 Advice应用(上)

为什么我testBiz是空指针报错

八月 16, 2017 9:16:14 下午 org.springframework.context.support.AbstractApplicationContext prepareRefresh

信息: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@1e0a283: startup date [Wed Aug 16 21:16:14 GMT+08:00 2017]; root of context hierarchy

八月 16, 2017 9:16:14 下午 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions

信息: Loading XML bean definitions from class path resource [resourse/spring-aop-advice.xml]

java.lang.NullPointerException

at test.UnitTestBase.getBean(UnitTestBase.java:34)

at spring.aop.advice.test.TestAOPAdvice.testBiz(TestAOPAdvice.java:16)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:606)

at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)

at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)

at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)

at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)

at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)

at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)

at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)

at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)

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.junit.runners.ParentRunner.run(ParentRunner.java:300)

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:459)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)


提问者:qq_较劲_0 2017-08-16 21:19

个回答

  • 昵称清溪被占用
    2017-08-29 09:35:46

    我刚刚把我的工程的jar包重新整理导入就已经都正常了,刚刚整理我的工程发现你是不是单词写错了???你的确定是resourse/spring-aop-advice.xml?不是resource或者resources么???那个地方是c不是s啊,以后尽量复制粘贴,在要导入文件上右键——>复制全限定名称,这样就算单词写错了,都是一样错,也是可以运行的

  • 昵称清溪被占用
    2017-08-29 09:14:04

    以后看报错信息优先看这样子的,其他都是调用的关联报错信息--->信息: Loading XML bean definitions from class path resource [resourse/spring-aop-advice.xml],重点检查XML名称,路径,aspect相关的jar包

  • 昵称清溪被占用
    2017-08-29 09:04:43

    http://img.mukewang.com/59a4bd2900018c8f02740155.jpg因为我现在已经换成了javaee了,所以程序现在不能运行了,可能是jar包冲突吧,反正新写的javaee的程序是正常的

  • 昵称清溪被占用
    2017-08-17 15:44:38

    刚刚学过,看不出来明显问题。。。知道大概是获取bean的时候出错了,你检查下xml配置文件,还有你的aopalliance-1.0.jar和aspectj-1.8.10.jar,还有aspectjweaver-1.5.3.jar导入了么?我之前是没有导入,老师也没有提醒。。。