springboot报错分析汇总(不定期更新)

  • Post author:
  • Post category:其他


  • org.springframework.web.servlet.HandlerExecutionChain – HandlerInterceptor.afterCompletion threw exceptionjava.lang.IllegalStateException: Cannot create a session after the response has been committedorg.apache.ibatis.binding.BindingException

有的人报这个错误,还有的人是正常的(排除clean的问题)

报错位置是主工程中模块里的mapper调用,exception是BindingException,考虑是sql文没找到造成的。

主工程已经写了模块的@ComponentScan,@MapperScan,mapper-locations,考虑是模块的jar没把sql的xml编译进去,查看jar确认。

定位模块的pom.xml的build修正,发现模块pom中没有加下记代码。当模块中没有需要编译的xml时可以不加,当有xml是必须加入下记代码,将它强制加入jar中。

 <build>
        <resources>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.xml</include>
                </includes>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <includes>
                    <include>**/*</include>
                </includes>
            </resource>
           </resources>
    </build>



版权声明:本文为thankna原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。