匯總下編寫SpringMVC項目時遇到的問題运授,省的以后再次碰到忘記再去百度
1、異常如下:
ERROR: org.springframework.web.context.ContextLoader - Context initialization failed
java.lang.NoClassDefFoundError: Lcom/dhcc/dao/BookShopDao;
可能原因:
1):缺少 org.springframework.asm-3.0.5.RELEASE.jar
2):溉奕。。
2忍啤、異常如下:
“通配符的匹配很全面, 但無法找到元素 'tx:advice' 的聲明”
解決:
xsi:schemaLocation 加上:
http://www.springframework.org/schema/txhttp://www.springframework.org/schema/tx/spring-tx.xsd
3加勤、異常如下
Build path is incomplete. Cannot find class file for org/hibernate/TransactionException
可能原因:Spring framework版本和Hibernate版本太低
可參考我的:
4仙辟、? Could not autowire method
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire method: 。鳄梅。叠国。
? ? ? ? Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [project.dao.ServiceUserDao] found for dependency:?
可能原因:
1)、<context component-scan base-package=""/> ?中包的路徑不對 戴尸,導(dǎo)致掃描不到相應(yīng)注解
添加如下jpa注解
5粟焊、異常:book is not mapped【selet * from book】
原因:hql查詢語句的表明是類名,首字母大寫
6孙蒙、如下:
java.lang.IncompatibleClassChangeError:classorg.springframework.core.type.classreading.ClassMetadataReadingVisitorhasinterfaceorg.springframework.asm.ClassVisitorassuperclass
解決:刪除Spring-asm-x.x.jar
具體原因參考:這里
7项棠、如下:
idea中web.xml配置 ? 某些元素出現(xiàn)element xxx is not allowed here
解決:右鍵項目名,open module settings, ?選擇web挎峦,指定web resources directories和Deployment Descriptions即可香追。
持續(xù)更新中。坦胶。透典。