spring boot+layui+mysql+mybatis-plus 项目建立过程中的bug

3 篇文章 0 订阅
3 篇文章 0 订阅
  1. 一开始只写了entity和mapper,进行测试的时候出现的bug

    AopAutoConfiguration matched:

    ​ @ConditionalOnProperty (spring.aop.auto=true) matched (OnPropertyCondition)

    翻译:AOP自动配置匹配:……

    这属于aop配置的问题,解决方法:

    需要在主类中扫包,即添加@MapperScan注解,把本项目对应的 mapper包扫描一下,主类代码如下所示(添加的那一行,就是@MapperScan("com.example.layuitest.mapper") ):

    package com.example.layuitest;
    
    import org.mybatis.spring.annotation.MapperScan;
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    
    @SpringBootApplication
    @MapperScan("com.example.layuitest.mapper")   //添加这一行
    public class LayuiTestApplication {
    
        public static void main(String[] args) {
            SpringApplication.run(LayuiTestApplication.class, args);
        }
    
    }
    
  2. mysql列名里面的下划线,在项目entity中封装时,需要转化为驼峰

    例如:a_fa 转化为 aFa

  3. 空指针异常

    java.lang.NullPointerException

    在这一部分中,大多数的数据已经查出来了,只是有一个数据,因为数据表之间对应不上(例如某商品的货号为1,但是在货号表中,没有货号1这个分类),所以查不到。因此查询代码是没有问题的。

    解决方法:先判断该数据是否为空,如果不为空,我们再进行查询。

    QueryWrapper wrapper = new QueryWrapper();
                wrapper.eq("id",product.getCategoryleveloneId());
                ProductCategory productCategory = productCategoryMapper.selectOne(wrapper);
                //判断是否为空,如果不为空,我们再进行查询
    		   if(productCategory!=null){
                    productVO.setCategorylevelone(productCategory.getName());
                }
    
  4. Spring boot配置全局跨域未生效,访问接口报错

  5. 注解错误:Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception

  6. Error resolving template [favicon.ico], template might not exist or might not be accessible by any of the configured Template Resolvers

    这属于:解析模板时出错

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值