1、在启动类中添加如下方法即可
报警告
public static void main(String[] args) {
disableWarning(); //禁用警告
SpringApplication.run(SecurityApplication.class, args);
}
//处理控制台异常
public static void disableWarning() {
try {
Field theUnsafe = Unsafe.class.getDeclaredField("theUnsafe");
theUnsafe.setAccessible(true);
Unsafe u = (Unsafe) theUnsafe.get(null);
Class cls = Class.forName("jdk.internal.module.IllegalAccessLogger");
Field logger = cls.getDeclaredField("logger");
u.putObjectVolatile(cls, u.staticFieldOffset(logger), null);
} catch (Exception e) {
// ignore
}
}
标签:JDK,theUnsafe,Unsafe,plus,mybatis,logger,警告,cls From: https://www.cnblogs.com/huxiaoan1/p/17334979.html时间:2023-04-19 晚上