本文共 1904 字,大约阅读时间需要 6 分钟。
2019-11-08 17:23:24.446 ERROR 215864 --- [ main] o.s.boot.SpringApplication : Application run failedorg.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'rabbitOrderSender': Unsatisfied dependency expressed through field 'brokerMessageLogMapper'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'brokerMessageLogMapper' defined in file [E:\学习\java\项目学习\springboot-rabbitmq\springboot-producer\target\classes\com\sxw\springbootproducer\mapper\BrokerMessageLogMapper.class]: Cannot resolve reference to bean 'sqlSessionFactory' while setting bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [com/sxw/springbootproducer/config/database/MybatisDataSourceConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method 'sqlSessionFactoryBean' threw exception; nested exception is java.lang.RuntimeException: java.io.FileNotFoundException: class path resource [com/sxw/springbootproducer/mapping/] cannot be resolved to URL because it does not exist
问题: 找不到URL指定的文件
出错位置:
这个位置找不到URL对应的文件
进一步分析,通过
得到解决办法:
报 xml找不到。可在:springboot-produce.pom 文件内添加如下代码:src/main/resources src/main/java **/*.properties **/*.xml false
为什么这么做可以?
先看rescources 标签的作用
从而得到错误原因:
由于没有配置resources 所以不会打包该路径下的文件到classpath, 然后就没有mapping这个文件夹,所以dataSource找不到URL,就报错。
转载地址:http://orqsi.baihongyu.com/