<build><plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-assembly-plugin</artifactId><version>2.5.5</version><configuration><archive><manifest><!-- 入口 main 方法所在类 改成自己的类名 --><mainClass>WriteTemplate</mainClass></manifest></archive><!-- 生成的jar包的后缀--><descriptorRefs><descriptorRef>jar-with-dependencies</descriptorRef></descriptorRefs></configuration><executions><execution><id>make-assembly</id><phase>package</phase><goals><goal>single</goal></goals></execution></executions></plugin></plugins><\build>
第二个问题就是在代码中用了poi来处理excel文件,但是打成的jar包或者直接用jar包打成的exe文件在处理时报错: java.io.IOException: Your InputStream was neither an OLE2 stream, nor an OOXML strprovide the poi-ooxml*.jar in the classpath/modulepath - FileMagic: OOXML, having providers: [org.apache.poi.hssf.usermodel.HSSFWorkbookFactory@1c65642a],该报错显示有两种错误可能,要么是提供的文件格式不对,要么是没有将poi-ooxml等jar包打进去,我在网上找了很长时间没有找到解决方法,最后想着要不自己在打成exe文件的时候将poi相关的几个jar包再打进去,这样就在classpath中有poi包了,说干就干,我尝试了一下,最后真的成功了,但是这种方法还是不能解决jar包会报错的问题,而exe文件可以正常运行,暂时就先这样弄着吧。