maven3 compile failed, class file not found issue

本文介绍了一个常见的Maven构建失败问题:在编译阶段出现class file未找到的错误。作者通过开启debug模式发现问题所在——某个依赖的jar文件未能加入到classpath中,并最终通过缩短仓库及代码路径解决了这一由Windows XP路径长度限制引发的问题。
今日maven3 build 老是失败,停在compile,报class file for XXX not found error,但是那个jar明明是在依赖里面啊。

后开debug模式,发现那个jar没有加到class path里面,可能是win XP下面万恶的路径长度限制吧,后缩短了仓库和代码的路径后,问题解决。
package com.example.demo8.service; import org.apache.tika.Tika; import org.apache.tika.metadata.Metadata; import org.apache.tika.parser.AutoDetectParser; import org.apache.tika.sax.BodyContentHandler; import org.apache.xmlgraphics.image.loader.ImageException; import org.apache.xmlgraphics.image.loader.ImageLoader; import org.apache.xmlgraphics.image.loader.ImageFlavor; import org.apache.xmlgraphics.image.loader.impl.DefaultImageContext; import org.xml.sax.ContentHandler; import javax.imageio.ImageIO; import java.awt.image.BufferedImage; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.util.Base64; import java.util.regex.Matcher; import java.util.regex.Pattern; public class RtfImageExtractor { private static final Pattern IMAGE_PATTERN = Pattern.compile( "\\{\\\\pict.*?\\\\wmetafile8.*?\\{(.*?)\\}\\}", Pattern.DOTALL | Pattern.MULTILINE ); public BufferedImage extractImage(byte[] rtfContent) throws IOException { String rtfText = new String(rtfContent); Matcher matcher = IMAGE_PATTERN.matcher(rtfText); if (matcher.find()) { String wmfData = matcher.group(1); byte[] wmfBytes = Base64.getDecoder().decode(wmfData); try (InputStream is = new ByteArrayInputStream(wmfBytes)) { return convertWmfToPng(is); } } throw new IOException("Image not found in RTF content"); } private BufferedImage convertWmfToPng(InputStream wmfStream) throws IOException { try { ImageLoader imageLoader = new ImageLoader(); DefaultImageContext context = new DefaultImageContext(); BufferedImage wmfImage = imageLoader.loadImage(wmfStream, context, ImageFlavor.RAW_PNG); return wmfImage; } catch (ImageException e) { throw new IOException("Failed to convert WMF to PNG", e);}}} 检查代码错误
最新发布
04-01
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值