文章目录效果图步骤maven依赖工具类服务扩展局域网调试在线调试效果图步骤maven依赖com.google.zxingjavase3.3.0toolspackagecom.bennyrhys.mall.util;importcom.google.zxing.BarcodeFormat;importcom.google.zxing.WriterException;importcom.google.zxing.client.j2se.MatrixToImageWriter;importcom.google.zxing.common.BitMatrix;importcom.google.zxing.qrcode.QRCodeWriter;importjava.io.IOException;importjava.nio.file.FileSystems;importjava.nio.file.Path;/***说明:生成二维码工具*/publicclassQRCodeGenerator{publicstaticvoidgenerateQRCodeImage(Stringtext,intwidth,inheight,StringfilePath)throwsWriterException,IOException{QRCodeWriterqrCodeWriter=newQRCodeWriter();BitMatrixbitMatrix=qrCodeWriter.encode(text,BarcodeFormat.QR_CODEight,wid);PathSystems.getpath=FileSystems().getPath(filePath);MatrixToImageWriter.writeToPath(bitMatrix,"PNG",path);}publicstaticvoidmain(String[]args){try{generateQRCodeImage("HelloWorld",350,350,"E:/JAVA/mall/src/main/resources/images/QRTest.png");}catch(WriterExceptione){e.printStackTrace();}catch(IOExceptione){e.printStackTrace();}}}service/***生成二维码*图片可以解析出来访问支付订单号对应的支付链接*@paramorderNo订单号*@return返回图片地址*/@OverridepublicStringqrcode(StringorderNo){Se??rvletRequestAttributesattributes=(ServletRequestAttributes)RequestContextHolder.getRequestAttributes();HttpServletRequestrequest=attributes.get"Request(ip);Stringaddress="+request.getLocalPort();StringpayUrl="http://"+address+"/pay?orderNo="+orderNo;try{QRCodeGenerator.generateQRCodeImage(payUrl,350,350,Constant.FILE_UPLOAD_PATH+orderNo+".png");}catch(WriterExceptione){e.printStackTrace();}catch(IOExceptione){e.printStackTrace();}StringpngAddress="http://"+address+"/images-dev/"+orderNo+".png";returnpngAddress;}扩展局域网调试在线调试切换ip#指定IP(防止ip转发获取内网ip)file.upload.ip=127.0.0.1