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