• springboot启动常见错误


    org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'checkItemServiceImpl': Unsatisfied dependency expressed through field 'baseMapper'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.ifjanuary.mapper.CheckItemMapper' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

    解决办法:在启动类上添加上包扫描

    @MapperScan("com.xxx.mapper")

    =============================================================================================================================================================

    ***************************
    APPLICATION FAILED TO START
    ***************************
    
    Description:
    
    Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
    
    Reason: Failed to determine a suitable driver class
    
    
    Action:
    
    Consider the following:
        If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
        If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).

    这是消费端,应该是不需要提供数据库连接的

    首先排查下消费端的pom文件中的依赖,把有关数据库连接的依赖删掉,一定要记得刷新maven仓库,我就是搞了很久一直是这个错,但是一刷新maven仓库就好了;

    如果是分为消费端和提供端的,可以把消费端的controller类放到提供端试试,看看在提供端能不能跑起来;

    之后再排查每个类所在的包和层级关系,我错把service接口放在了pojo包下,最后是解决了,所以在搬砖时一定要认真

    =============================================================================================================================================================

    java.lang.IllegalStateException: Serialized class com.ifjanuary.pojo.CheckItem must implement java.io.Serializable

    在实体类中实现接口

    Serializable

    ====================================================================================================================================================================================

    javax.servlet.ServletException: Circular view path [selectSetmealRate]: would dispatch back to the current handler URL [/xxxxxx] again. Check your ViewResolver setup! (Hint: This may be the result of an unspecified view, due to default view name generation.)

    因为返回前端需要json格式的数据,可以直接在controller层加上注解:

    //@Controller
    @RestController 不用@Controller
    也可以
    在方法上加注解@responsebody 选其一就好
  • 相关阅读:
    CSS(22)CSS的长度单位
    CSS(21)CSS Grid网格布局
    CSS(20)CSS3 弹性盒子(Flex Box)
    CSS(19)CSS3 多列
    CSS(18)CSS3 过渡与动画
    CSS(17)CSS 2D、3D 转换
    CSS(16)CSS3 渐变(Gradients)
    CSS(15)CSS媒体查询Media Queries
    CSS(14)CSS 伪元素
    CSS(13)CSS 伪类(Pseudo-classes)
  • 原文地址:https://www.cnblogs.com/if-january/p/14046638.html
Copyright © 2020-2023  润新知