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 选其一就好