Maven web project error "import com.sun.image.codec.jpeg.*"

来源:互联网 发布:淘宝小号查询源码 编辑:程序博客网 时间:2024/05/16 11:18

Maven web project error “import com.sun.image.codec.jpeg.*”

This was my third time to write blog on CSDN.

First of all, you should know which *.jar the class “com.sun.image.codec.jpeg” depended on.

It was “rt.jar” and “jce.jar” included in the local JDK.

  • If you run as “maven build” local maven(webapp)-tomcat projecet, there was a error about “com.sun.image.codec.jpeg”.
    You can “Add Library local JDK” by “project->properties(Alt+Enter)->Java Build Path->Libraries->Add Library->JRE System Library”.

  • If you want to pack as *.war automatically and deploy on Jenkins, there was a way to slove.

    Due to that Maven Dependencies did not include local JDK, you should put “rt.jar” and “jce.jar” into POM.XML.
    Add plugin, such as:

<plugin>    <groupId>org.apache.maven.plugins</groupId>    <artifactId>maven-compiler-plugin</artifactId>    <version>3.3</version>    <configuration>        <source>1.7</source>        <target>1.7</target>        <fork>true</fork>        <compilerArguments>            <verbose />            <bootclasspath>            C:\Program Files (x86)\Java\jdk1.7.0_25\jre\lib\rt.jar;            C:\Program Files (x86)\Java\jdk1.7.0_25\jre\lib\jce.jar            </bootclasspath>        </compilerArguments>          <executable>        C:\Program Files (x86)\Java\jdk1.7.0_25\bin\javac.exe        </executable>    </configuration></plugin>

PS 1: In “source” and “target”, the “1.7”was version of the server’s JDK.
PS 2: The “C:\Program Files (x86)\Java\jdk1.7.0_25” was the path of the server’s JDK.
PS 3: If you deployed it on local Jenkins, the server’s JDK just was your own JDK.

Of course, if finding dependencies as those and add into pom.xml, project also can work.

<dependency>    <groupId>***</groupId>    <artifactId>rt</artifactId>    <version>*.*</version></dependency><dependency>    <groupId>***</groupId>    <artifactId>jce</artifactId>    <version>*.*</version></dependency>

But I could not find now.

1 0