将逆向生成的文件粘贴到项目中,出现以下报错

将逆向生成的文件粘贴到项目中,出现以下报错

相关截图:

https://img1.sycdn.imooc.com//climg/64d7027e09a7aa0628541724.jpg

问题描述:

Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalStateException: Cannot load driver class: com.mysql.jdbc.Driver


正在回答

登陆购买课程后可参与讨论,去登陆

1回答

参考一下逆向工具里的数据源,你的数据库不匹配就是要改的,其实控制台里的报错也很明显,直接复制粘贴换一下就行。

  • 甘炽文 提问者 #1

    老师还是不行,会报配置文件错误

    Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [tk/mybatis/mapper/autoconfigure/MapperAutoConfiguration.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 org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [/Users/我的文件/软件开发/foodie-dev/foodie-dev-mapper/target/classes/mapper/UsersMapper.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. The XML location is 'file [/Users/我的文件/软件开发/foodie-dev/foodie-dev-mapper/target/classes/mapper/UsersMapper.xml]'. Cause: java.lang.IllegalArgumentException: Result Maps collection already contains value for com.imooc.mapper.UsersMapper.BaseResultMap

    https://img1.sycdn.imooc.com//climg/64d73615090dd25c28641630.jpg

    2023-08-12 15:35:01
  • 风间影月 回复 提问者 甘炽文 #2
    你的mapper文件打开看看,是不是有重复的,这玩意不能重复生成,其实很多错误看日志是可以获得错误的原因的
    2023-08-12 17:19:36
  • 甘炽文 提问者 回复 风间影月 #3

    https://img1.sycdn.imooc.com//climg/64d84174091a396f25581236.jpg

    https://img1.sycdn.imooc.com//climg/64d8418c0973ba4b21501148.jpg

    没有重复文件生成,都是单一的

    2023-08-13 10:36:35
问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
请稍等 ...
意见反馈 帮助中心 APP下载
官方微信

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师