當(dāng)前位置:
首頁 >
前端技术
> javascript
>内容正文
javascript
Spring 菜鸟教程 异常 集锦
生活随笔
收集整理的這篇文章主要介紹了
Spring 菜鸟教程 异常 集锦
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
異常1.空指針異常
異常信息摘要:
java.lang.NullPointerExceptionat com.jege.framework.service.UserServiceTest.get(UserServiceTest.java:36)異常信息說明:server接口沒有注入
解決思路:可能的原因:
異常2.bean的名字name或者id已經(jīng)存在
異常信息摘要:
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Bean name 'helleService' is already used in this <beans> element異常信息說明:helleService bean對象已經(jīng)存在
解決思路:把重復(fù)的名字改一下:
異常3.web項目找不到默認配置文件
異常信息摘要:
org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [applicationContext.xml]; nested exception is java.io.FileNotFoundException: class path resource [WEB-INF/applicationContext.xml] cannot be opened because it does not exist異常信息說明:web項目默認會在WEB-INF下找applicationContext.xml配置文件
解決思路:在web.xml配置一個上下文屬性:
異常4.命名空間配置錯誤
異常信息摘要:
nested exception is org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'aop:confog'.異常信息說明:沒有找到aop:confog的配置
解決思路:配置好schema的aop命名空間
異常5.bean不是唯一的異常
異常信息摘要:
org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [com.jege.ssh.dao.IUserDao] is defined: expected single matching bean but found 2: UserDao1,UserDao2at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:313)異常信息說明:注入的接口有2個實現(xiàn)
解決思路:去掉一個實現(xiàn)類,一個接口最好只有一個實現(xiàn)
異常6.bean沒有定義,不存在
異常信息摘要:
org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'userDao' is defined異常信息說明:userDao沒有定義
解決思路:在applicationContext.xml中找不到id為userDao的bean,配置一下或者注解沒有標注@Repository
異常7.server接口沒有注入
異常信息摘要:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.jege.framework.service.UserServiceTest': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.jege.framework.service.IUserService com.jege.framework.service.UserServiceTest.userService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.jege.framework.service.IUserService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.jege.framework.service.IUserService com.jege.framework.service.UserServiceTest.userService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.jege.framework.service.IUserService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.jege.framework.service.IUserService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}異常信息說明:server接口沒有注入
解決思路:可能的原因:
異常8.aspectjweaver-1.8.0.jar spring4要使用高版本
如果覺得我的文章或者代碼對您有幫助,可以請我喝杯咖啡。
您的支持將鼓勵我繼續(xù)創(chuàng)作!謝謝!
總結(jié)
以上是生活随笔為你收集整理的Spring 菜鸟教程 异常 集锦的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Spring Boot 菜鸟教程 1 H
- 下一篇: Spring 菜鸟教程 Introspe