zoukankan      html  css  js  c++  java
  • 搭建基础项目遇到的一些小坑

    最近看到一个秒杀系统,本来打算自己本地走个test,没想到好久不搭建项目,一下子走了好多坑,话不多说

    1.在启动类这里写dao.*

    @MapperScan(basePackages = "com.example.demo.*")
    此处会报错,详情如下,找不到service
    org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.example.demo.Service.MiaoshaService.miaoshaGoods
    这里需要写具体路径,具体到dao层路径
    @MapperScan(basePackages = "com.example.demo.dao")

    2.在上面如果是报dao的错

    org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.example.demo.Dao.MiaoshaDao.miaoshaGoods
    建议去看下xml中的namespace是否与dao匹配

    3.本地项目启动需要写明xml位置

    这里我是用的yml需要写好配置
    mybatis:
    mapper-locations: classpath*:mapper/*.xml

    4.如果需要打包,需要在配置文件pom中加入以下配置

    <resources>
    <resource>
    <directory>src/main/java</directory>
    <includes>
    <include>**/*.xml</include>
    <include>*.yml</include>
    </includes>
    <filtering>true</filtering>
    </resource>
    <resource>
    <directory>src/main/resources</directory>
    <includes>
    <include>**/*.xml</include>
    <include>*.yml</include>
    </includes>
    <filtering>true</filtering>
    </resource>
    </resources>

    5.别忘记配置数据库

    报错如:Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
    需要在pom中引包
    <dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <scope>runtime</scope>
    </dependency>
    并在yml中配置
    datasource:
    url: jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&allowMultiQueries=true
    username: root
    password: root
    driver-class-name: com.mysql.jdbc.Driver

    上面就是简单搭建项目遇到的小坑

  • 相关阅读:
    选择正确的API从SQL Server获取XML数据
    XmlTextWriter学习笔记[转]
    简单的在线RSS阅读器[转]
    如何从客户端 JavaScript 调用 .NET Web 服务使用 InternetExplorer 和 MSXML
    用xmlhttp将html的数据打包成multipart/formdata格式,实现异步上传文件功能[转]
    ASP.Net中MD5加密16位32位
    第一个XMLHTTP测试成功![原创]
    php目录操作函数
    原创JS幻灯片效果,超少代码
    PHP MVC设想,MVC框架构思(一)
  • 原文地址:https://www.cnblogs.com/innocenter/p/12802673.html
Copyright © 2011-2022 走看看