SpringBoot启动报错

1.错误创建xxxcontroller、xxxservice、xxxserviceImpl ...

2.com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: Error: Global ...

 

SpringBoot刚启动时,有时候会报上面两种错误。当将所有可能是代码引起该错误的情况都排除后还是报错,走投无路了,那么可以考虑这两种错误是由于配置文件中的url不合适引起,只需要更改一下resources下的配置文件application.properties中的 spring.datasource.url 就行了:

这里有几种,试着来:

  (1)spring.datasource.url=jdbc:mysql://localhost:3306/mybatis_plus?serverTimezone=GMT%2B8
  (2)spring.datasource.url=jdbc:mysql://localhost:3306/mybatis_plus?useUnicode=true&characterEncoding=utf8&useSSL=false
  (3)spring.datasource.url=jdbc:mysql://localhost:3306/mybatis_plus?autoReconnect=true&useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8

 

 

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

2.项目启动报错:

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [com/baomidou/mybatisplus/autoconfigure/MybatisPlusAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method 'sqlSessionFactory' threw exception; nested exception is com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: Error: GlobalConfigUtils setMetaData Fail !  Cause:com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure

再数据源连接url后面添加:

&useSSL=false

eg:

jdbc:mysql://localhost:3306/test?serverTimezone=GMT%2B8&useSSL=false

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

posted @ 2021-09-13 14:52  sensen~||^_^|||&  阅读(316)  评论(0)    收藏  举报