项目场景:

springboot项目启用热部署后出现问题

问题描述:

Caused by: java.lang.IllegalStateException: Illegal access: this web application instance has been stopped already. Could not load [mapper/]. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.
	at org.apache.catalina.loader.WebappClassLoaderBase.checkStateForResourceLoading(WebappClassLoaderBase.java:1385) ~[tomcat-embed-core-9.0.35.jar:9.0.35]
	at org.apache.catalina.loader.WebappClassLoaderBase.getResource(WebappClassLoaderBase.java:1038) ~[tomcat-embed-core-9.0.35.jar:9.0.35]


原因分析:

关键字不能加载[mapper/]。
springBoot 使用了spring-boot-devtools,热部署后加载mybatis映射文件找不到对应目录造成的;


解决方案:

方案一:禁用热加载
application.properties配置对应属性为false

spring.devtools.restart.enabled=false

方案二:

设application.properties

mybatis.mapperLocations=classpath*:mapper/*.xml

(使用classpath*:替换之前的classpath:来告诉spring查找所有classpath)

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐