因为组织架构调整,被调去别的项目组,后端用的是spring boot,
报错信息时下面这个,报错信息只能给这些,其他的报错信息有公司的标志不能展示(这个是初始化数据库连接创建sqlSessionFactory
报的异常)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory'
defined in class path resource [org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]:
Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException:
Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method 'sqlSessionFactory' threw exception;
nested exception is java.lang.ExceptionInInitializerError
最后debug解决了
原由:
Springboot项目在起服务时需要读取加密数据库的配置文件,是一个properties,但是别人可以本地拉起服务,而我不可以,
出现的原因
最后看异常,说是文件中的某个key不存在,通过debug发现在内置的代码中读取properties的路径是根据内置的读取加密类的class的路径获取的,通过相对路径获得绝对路径,没问题,但是我的项目的有一层目录有空格,造成了路径中出现了 %20,这样文件根本读取不到,所以properties
就为null了,那里面肯定就没有数据了