日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 前端技术 > javascript >内容正文

javascript

Spring 菜鸟教程 异常 集锦

發(fā)布時間:2023/12/2 javascript 53 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Spring 菜鸟教程 异常 集锦 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

異常1.空指針異常

異常信息摘要:

java.lang.NullPointerExceptionat com.jege.framework.service.UserServiceTest.get(UserServiceTest.java:36)

異常信息說明:server接口沒有注入
解決思路:可能的原因:

1.xml版本,沒有寫set方法,spring配置文件配置注入寫的有問題 2.注解版本,沒有寫@Autowired或者@Resource 3.測試類上面沒有標注 @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("classpath:applicationContext.xml")

異常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配置一個上下文屬性:

<context-param><param-name>contextConfigLocation</param-name><param-value>classpath:applicationContext.xml</param-value> </context-param>

異常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命名空間

xmlns:aop="http://www.springframework.org/schema/aop" http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd

異常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接口沒有注入
解決思路:可能的原因:

1.xml版本,沒有寫set方法,spring配置文件配置注入有問題 2.注解版本,<context:component-scan base-package="com.jege.framework包寫錯" />

異常8.aspectjweaver-1.8.0.jar spring4要使用高版本


如果覺得我的文章或者代碼對您有幫助,可以請我喝杯咖啡。
您的支持將鼓勵我繼續(xù)創(chuàng)作!謝謝!

總結(jié)

以上是生活随笔為你收集整理的Spring 菜鸟教程 异常 集锦的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。