用一个类出现同一个类报cannot be cast to,不能强制转换,服务器错误500
javajava.xxxx.xxxx cannot be cast to java.xxxx.xxxx
可能是SpringBoot热部署的问题,导致虽然是同一个类但是由于是不同的类加载器加载导致,他们是不同的从而转换异常
pom文件中注释掉热部署的依赖
xml<!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-devtools</artifactId>-->
<!-- <optional>true</optional>-->
<!-- </dependency>-->
放置常用的一些响应信息
javapublic enum ResultCodeEnum {
ERROR(100, "系统错误"),
SUCCESS(200, "操作成功"),
FAILED(500, "操作失败");
VALIDATE_FAILED(404, "参数检验失败"),
UNAUTHORIZED(401, "暂未登录或token已经过期"),
FORBIDDEN(403, "没有相关权限");
// 自定义状态码
private final int code;
// 自定义描述
private final String msg;
ReturnCode(int code, String msg){
this.code = code;
this.msg = msg;
}
public int getCode() {
return code;
}
public String getMsg() {
return msg;
}
}
maven下载配置成国内镜像提高下载速度
文件路径:D:\maven\apache-maven-3.6.0\conf\settings.xml
xml<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<!-- localRepository
| The path to the local repository maven will use to store artifacts.
|
| Default: ${user.home}/.m2/repository
-->
<localRepository>D:\maven\repository</localRepository>
提示身份证明检索失败
如果不存在,则直接添加SQLNET.AUTHENTICATION_SERVICES= (NONE)
java枚举类是一组预定义常量的集合,使用enum关键字声明这个类,常量名称官方建议大写
举一个常见的例子,例如星期就可以描述为一个枚举类,如下
javapublic enum Day {
SUNDAY, MONDAY, TUESDAY, WEDNESDAY,THURSDAY, FRIDAY, SATURDAY
}
怎么调用呢,Java switch语句参数就支持enum类
javapublic class EnumTest {
Day day;
public EnumTest(Day day) {
this.day = day;
}
public void tellItLikeItIs() {
switch (day) {
case MONDAY:
System.out.println("周一各种不在状态");
break;
case FRIDAY:
System.out.println("周五感觉还不错");
break;
case SATURDAY: case SUNDAY:
System.out.println("周末给人的感觉是最棒的");
break;
default:
System.out.println("周内感觉就那样吧。。。");
break;
}
}
public static void main(String[] args) {
EnumTest firstDay = new EnumTest(Day.MONDAY);
firstDay.tellItLikeItIs();
EnumTest thirdDay = new EnumTest(Day.WEDNESDAY);
thirdDay.tellItLikeItIs();
EnumTest fifthDay = new EnumTest(Day.FRIDAY);
fifthDay.tellItLikeItIs();
EnumTest sixthDay = new EnumTest(Day.SATURDAY);
sixthDay.tellItLikeItIs();
EnumTest seventhDay = new EnumTest(Day.SUNDAY);
seventhDay.tellItLikeItIs();
}
}