我的构造函数里面报空指针异常了!求大神帮忙

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了我的构造函数里面报空指针异常了!求大神帮忙相关的知识,希望对你有一定的参考价值。

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'shiroFilter' defined in class path resource [spring/applicationContext-shiro.xml]: Cannot resolve reference to bean 'securityManager' while setting bean property 'securityManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'securityManager' defined in class path resource [spring/applicationContext-shiro.xml]: Cannot resolve reference to bean 'customRealm' while setting bean property 'realm'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'customRealm': Unsatisfied dependency expressed through field 'imUserService': Error creating bean with name 'imUserService' defined in class path resource [spring/applicationContext-service.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.sinosoft.sinoims.service.impl.ImUserServiceImpl]: Constructor threw exception; nested exception is java.lang.NullPointerException; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'imUserService' defined in class path resource [spring/applicationContext-service.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.sinosoft.sinoims.service.impl.ImUserServiceImpl]: Constructor threw exception; nested exception is java.lang.NullPointerException
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:359)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1481)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1226)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)

Caused by: java.lang.NullPointerException
at com.sinosoft.sinoims.util.SpringUtils.getBean(SpringUtils.java:44)
at com.sinosoft.sinoims.service.impl.ImUserServiceImpl.<init>(ImUserServiceImpl.java:29)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:142)
... 94 more

从最后一段可以看出,是你的ImUserServiceImpl.java类里面的29行有问题,而且后面说问题就出在BeanUtils这个方法上里有问题,所以是注入失败问题。使用注解配置试试看。追问

厉害啦,问题真实这样,已解决!

参考技术A 我,鲁智深,无话可说追问

???

以上是关于我的构造函数里面报空指针异常了!求大神帮忙的主要内容,如果未能解决你的问题,请参考以下文章

在Eclipse运行junit test的时候出现空指针异常的情况,求大神帮帮忙啊

JSONObject.getString()报空指针错误,求帮助

java中String browser = request.getHeader(&amp;quot;user-agent&amp;quot;)报空指针异怎么解决

java 泛型函数需要返回Integer 我返回null 为啥报空指针异常

jsoup解析本地html文件,老是报空指针错误,求大神指导,小菜鸟一枚,代码如下:

大神来解答,JAVA中,我想用一个类存放多个数据,为啥报空指针错误?(代码如下)