springboot +docker+tomcat
Caused by: java.lang.UnsatisfiedLinkError: /usr/local/openjdk-8/jre/lib/amd64/libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory
一开始使用的Tomcat镜像是slim版本,以为缺少包,后改成了tomcat:8.5.55-jdk8-corretto,出现了【报错2】
Caused by: java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager
之后在网上查,各种说加什么 JAVA_OPTS headless 为 true 的,不过在基于 docker springboot 的都不好使。
最终还是从代码层面手工设置了 System.setProperty("java.awt.headless","true"); 解决问题。
@SpringBootApplication public class EbootApplication { public static void main(String[] args) { System.setProperty("java.awt.headless", "true"); SpringApplication.run(EbootApplication.class, args); } }
PS:什么是Headless mode?Headless模式是系统的一种配置模式。在该模式下,系统缺少了显示设备、键盘或鼠标。
一般是在程序开始激活headless模式,告诉程序,现在你要工作在Headless mode下,就不要指望硬件帮忙了,自力更生并依靠系统的计算能力模拟出这些特性来。
https://blog.csdn.net/catoop/article/details/97133086