1、问题?项目打包报错;
程序包com.sun.image.codec.jpeg不存在;
在使用Hudson进行打包的过程中,因为我们使用了一个pdf文件产生缩略图的功能,倒置添加的源码文件在maven下面编译失败,失败提示信息为:程序包com.sun.image.codec.jpeg不存在 后来查看这个类文件的位置在jre/lib/rt.jar
而我们设置的java_home下面的lib/dt.jar中没有这个文件,导致编译失败。通过配置maven-compiler-plugin插件可以解决此问题。
- 然后查看了一下工程的java build path 里的libraries 下面maven depends 的jar包是不是缺少了,果然发现缺少jdk.tools-1.7.jar,
先直接上解决方法:在项目的pom.xml 中增加以下maven依赖配置,再编译就
- <dependency>
- <groupId>jdk.tools</groupId>
- <artifactId>jdk.tools</artifactId>
- <version>1.7</version>
- <scope>system</scope>
- <systemPath>${JAVA_HOME}/lib/tools.jar</systemPath>
- </dependency>
<build>
<plugins><plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<encoding>UTF-8</encoding>
<compilerArguments>
<verbose/> <!-- 解决缺少包 -->
<bootclasspath>${JAVA_HOME}\jre\lib\rt.jar;${JAVA_HOME}\jre\lib\jce.jar;${JAVA_HOME}\lib\tools.jar</bootclasspath>
</compilerArguments>
</configuration></plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration> <!-- Tests are skipped. -->
<skip>true</skip>
</configuration>
</plugin>
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building HTX3开发管理后台 1.0.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ aop-security ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 270 resources
[INFO]
[INFO] --- maven-compiler-plugin:2.0.2:compile (default-compile) @ aop-security ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ aop-security ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\b\WorkSpaces\aop-security\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.0.2:testCompile (default-testCompile) @ aop-security ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.19.1:test (default-test) @ aop-security ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-war-plugin:2.2:war (default-war) @ aop-security ---
[INFO] Packaging webapp
[INFO] Assembling webapp [aop-security] in [D:\b\WorkSpaces\aop-security\target\aop-security-1.0.0]
[INFO] Processing war project
[INFO] Copying webapp resources [D:\b\WorkSpaces\aop-security\src\main\webapp]
[INFO] Webapp assembled in [12377 msecs]
[INFO] Building war: D:\b\WorkSpaces\aop-security\target\aop-security-1.0.0.war
[INFO] WEB-INF\web.xml already added, skipping
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ aop-security ---
[INFO] Installing D:\b\WorkSpaces\aop-security\target\aop-security-1.0.0.war to D:\mavenspaces\repo\com\casic\aop-security\1.0.0\aop-security-1.0.0.war
[INFO] Installing D:\b\WorkSpaces\aop-security\pom.xml to D:\mavenspaces\repo\com\casic\aop-security\1.0.0\aop-security-1.0.0.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 35.504 s
[INFO] Finished at: 2018-04-11T13:51:37+08:00
[INFO] Final Memory: 16M/981M
[INFO] ---------------------------------------