问答详情
源自:3-11 用户模型管理--用户注册功能实现02

找不到“UserDOMapper”类型的bean

https://img.mukewang.com/5c41fcf500018b3b12340613.jpg

这里是怎么出错了   我重新写了一遍还是不行...

提问者:qq_罪名_1 2019-01-19 00:21

个回答

  • weixin_慕妹3329874
    2019-01-23 23:40:39

    把你的邮箱发我,我可以把整个项目的代码都给你。mybatis-generator.xml和application.properties文件同时位于resources的根目录下面

  • weixin_慕妹3329874
    2019-01-19 19:05:45

    应该是你的mapper.xml文件有问题。mybatis-generator.xml是mybatis生成的配置文件,位于resources目录下面。

  • qq_罪名_1
    2019-01-19 17:57:30

    2019-01-19 17:56:31.762  INFO 8904 --- [nio-8090-exec-2] com.alibaba.druid.pool.DruidDataSource   : {dataSource-1} inited

    2019-01-19 17:56:32.212  INFO 8904 --- [nio-8090-exec-2] o.s.b.f.xml.XmlBeanDefinitionReader      : Loading XML bean definitions from class path resource [org/springframework/jdbc/support/sql-error-codes.xml]

    2019-01-19 17:56:32.395  WARN 8904 --- [nio-8090-exec-2] .m.m.a.ExceptionHandlerExceptionResolver : Resolved [org.springframework.jdbc.BadSqlGrammarException: 

    ### Error updating database.  Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

    ### The error may involve com.miaoshaproject.dao.UserPasswordDOMapper.insertSelective-Inline

    ### The error occurred while setting parameters

    ### SQL: insert into user_password

    ### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

    ; bad SQL grammar []; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1]


  • weixin_慕妹3329874
    2019-01-19 10:41:50

    看你的mybatis-generator里面设置sqlMapGenerator了没有。

    <sqlMapGenerator targetPackage="mapping"  targetProject="src/main/resources">
        <property name="enableSubPackages" value="true" />

    然后,再看application.properties里面设置了mybatis.mapper-locations了没有。

    mybatis.mapper-locations=classpath:mapping/*.xml

    启动的应用程序需要加上下面两个注解。里面的包名换成你自己实际对应的包名。

    @SpringBootApplication(scanBasePackages = {"cn.ancony.seckill"})
    @MapperScan("cn.ancony.seckill.dao")


  • weixin_慕妹3329874
    2019-01-19 04:01:31

    这个没关系~只要运行没问题就行。