一、字體問題
在 Linux 環境 Java11 在驗證碼和 Excel 部分功能會使用到字體,這就觸發 Java11 的字體問題。
解決方案:
創建fontconfig.properties文件
在 $JAVA_HOME/lib 目錄下創建 fontconfig.properties 文件。
內容如下:
version=1
sequence.allfonts=default
安裝字體
sudo yum install fontconfig
sudo yum install urw-fonts
sudo fc-cache -f
詳情可以查看 open jdk github issues:https://github.com/AdoptOpenJ...
二、javax.xml.bind 不存在
Java11 刪除了 Java EE modules,其中就包括 java.xml.bind (JAXB)。
啟動時提示
WARNING: Illegal reflective access by com.thoughtworks.xstream.core.util.Fields (file:/com/thoughtworks/xstream/xstream/1.4.10/xstream-1.4.10.jar) to field java.util.TreeMap.comparator
解決方案就是你可以手動添加相關依賴。
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.3.0</version>
</dependency>
詳細情況可以查看:https://stackoverflow.com/que...
三、編譯報錯
由於刪除部分API,以下類找不到
sun.misc.BASE64Encoder、sun.misc.BASE64Decoder
解決步驟: 使用java.util.Base64.Encoder、java.util.Base64.Decoder替換
四、內置容器無法啟動
當我們使用 Eureka 作為注冊中心時,由於移除依賴的JAXB模塊。
The JAXB modules which the Eureka server depends upon were removed in JDK 11. If you intend to use JDK 11 when running a Eureka server you must include these dependencies in your POM or Gradle file.
需要手動引入:
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
</dependency>
原文地址:https://segmentfault.com/a/1190000021812685