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

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

  • 相关阅读:
    懒加载数据,在取出数据时容易出的bug....
    小程序申请及小程序发布
    SSL证书申请及安装
    iview modal 覆盖问题
    取消div独占一行的特性
    GPS坐标互转:WGS-84(GPS)、GCJ-02(Google地图)、BD-09(百度地图)、(百度坐标转谷歌坐标)
    工厂方法模式
    STS创建SpringBoot项目
    snmp协议学习记录
    操作系统命令学习记录
  • 原文地址:https://www.cnblogs.com/innocenter/p/12802673.html
Copyright © 2011-2022 走看看