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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章