文章目录
MySQL异常
SQL异常
- 错误原因:SQL时区没有设置,这个是因为springboot默认使用的MySQL是8.0以上的版本,我们使用的是5.0的版本。
- 解决方法:增加一个时区配置:serverTimezone=UTC
spring:
datasource:
username: root
password: 123456
#假如时区报错了,就增加一个时区配置:serverTimezone=UTC
url: jdbc:mysql://localhost:3306/mybatisdb?useUnicode=true&characterEncoding=utf-8&serverTimezone=UTC
driver-class-name: com.mysql.cj.jdbc.Driver
springboot整合Druid时出现的异常
由于 /** 与 /* 造成的异常
在基于springBoot框架整合Druid时,在DruidConfig
配置类配置对应的ServletRegistrationBean
时,路径不小心填写了/druid/**
,导致了本地访问时,无法跳转DRUID的监控登陆页面而是报了404错误,当后来修改为/druid/*
时,则可以正常访问login页面。
/druid/**
时
ServletRegistrationBean bean =
new ServletRegistrationBean(new StatViewServlet(), "/druid/**");
ServletRegistrationBean bean =
new ServletRegistrationBean(new StatViewServlet(), "/druid/*");
/*
与/**
的区别:
/*是指代下面的一级路径 不包括其子目录下的资源
/**是指代的下面的全部路径 包括其子目录的下的资源。
shiro框架
出现NoClassDefFoundError
出现这样的错误是因为pom.xml里缺少了一个依赖。
解决方法是添加
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
</dependency>
修改后的pom.xml文件是
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>springboot-08-shiro</artifactId>
<groupId>com.zhu</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>hello-shiro</artifactId>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-core</artifactId>
<version>1.4.1</version>
</dependency>
<!-- Shiro uses SLF4J for logging. We'll use the 'simple' binding
in this example app. See http://www.slf4j.org for more info. -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.21</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>1.7.21</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
</dependency>
</dependencies>
</project>
修改过后重新启动,输出结果为;
StackOverflowError
java.lang.StackOverflowError: null
意思是:出现栈内存溢出的常见原因有2个:
- 函数递归调用层次过深,每调用一次,函数的参数、局部变量等信息就压一次栈,并且没有及时出栈。
- 局部静态变量体积太大
错误原因是,controller接口自己调用了自己,因此形成了死循环,直至内存溢出。
解决方法是: