一、問題現象java
上傳圖片功能,本地測試編譯須要引用插件,不然編譯不經過;web
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>utf-8</encoding>
<compilerArguments>
<verbose />
<bootclasspath>${java.home}/lib/rt.jar:${java.home}/lib/jce.jar</bootclasspath>
<!--<bootclasspath>${java.home}\lib\rt.jar;${java.home}\lib\jce.jar</bootclasspath>-->
</compilerArguments>
</configuration>spring
</plugin>
</plugins>
</build>
而後本地測試經過,可是發佈到測試環境報錯,org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.NoClassDefFoundError: com/sun/image/codec/jpeg/ImageFormatExceptionvim
二、緣由maven
上傳壓縮圖片用到com.sun包的內容,可是測試環境用的java openjdk,lib下面的rt.jar裏面沒有 com/sun/image/codec/jpeg這個包,致使引用不到這個類測試
三、解決方式:安裝標準的jdkui
cd /etcspa
vim profile插件
export JAVA_HOME=/usr/local/jdk8
export CLASSPATH=.:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar
export PATH=$JAVA_HOME/bin:$HOME/bin:$HOME/.local/bin:$PATHcode
source profile
java -version