spring项目常见异常以及错误总结(一)

1.异常描述
org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'xxx' defined in URL[file:/xxxx/xxx.xml]: Could not resolve place holder 'xxx' in string value 'xxx': nexted exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'xxxx' in string value 'xxx'
 

原因:

<context:property-placeholder location="classpath:jdbc.properties"/>

  <context:property-placeholder location="classpath:redis.properties"/>

 原因分析:是否存在多个context:property-placeholder,在spring中只会使第一个生效,其后的被忽略,如果需要配置多个properties,在location中使用逗号隔开即可。如location="classpath:xxx1.properties,classpath:xxx2.properties"
 

应该为:<context:property-placeholder location="classpath:jdbc.properties,classpath:redis.properties"/>

2.

tomcat控制台乱码,解决:

在tomcat根目录下的conf目录下找到logging.properties,打开后将UTF-8全部替换成GBK即可

3.org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in file [D:\搜狗高速下载\apache-tomcat-9.0.22-windows-x64\apache-tomcat-9.0.22\webapps\ssm_war\WEB-INF\classes\spring\spring-dao.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [D:\搜狗高速下载\apache-tomcat-9.0.22-windows-x64\apache-tomcat-9.0.22\webapps\ssm_war\WEB-INF\classes\mapper\OrderDao.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: java.lang.NullPointerException
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1566)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
   

错误原因:mapper文件忘了填namespace

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值