后端学习踩坑之旅,持续更新中~

这次是使用Spring连接数据库的问题
报错:信息: Illegal access: this web application instance has been stopped already. Could not load . The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact.
原因:Caused by: java.io.FileNotFoundException: Could not open ServletContext resource [/jdbc.properties]
解决办法:在SpringConfig文件中修改jdbc配置的路径,添加classpath:
修改前:

@Configuration
@ComponentScan({"com.fxy.dao", "com.fxy.domain", "com.fxy.service"})
@PropertySource("jdbc.properties")
@Import({JdbcConfig.class, MybatisConfig.class})
public class SpringConfig {
}

修改后:

@Configuration
@ComponentScan({"com.fxy.dao", "com.fxy.domain", "com.fxy.service"})
@PropertySource("classpath:jdbc.properties")
@Import({JdbcConfig.class, MybatisConfig.class})
public class SpringConfig {
}

重启Tomcat就成功了。


版权声明:本文为fxy962454244原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/fxy962454244/article/details/124831964