• maven本地化jbarcode-0.2.7.jar


    jbarcode-0.2.7.jar

    • 1.cmd命令进入该jar包所在路径
    • 2.执行命令:
    mvn install:install-file -Dfile=jbarcode-0.2.7.jar -DgroupId=org.jbarcode -DartifactId=jbarcode -Dversion=0.2.7 -Dpackaging=jar
    
    • 1

    说明:-DgroupId和-DartifactId的作用是指定了这个jar包在repository的安装路径,只是用来告诉项目去这个路径下寻找这个名称的jar包。
    mvn install:install-file -Dfile=jbarcode-0.2.7.jar -DgroupId=org.jbarcode -DartifactId=jbarcode -Dversion=0.2.7 -Dpackaging=jar
    就是指把jbarcode-0.2.7.jar安装到—目录下,执行完命令后,如果需要在项目中使用这个jar,则在pom.xml中添加如下配置即可:

    
    org.jbarcode
    jbarcode
    0.2.7
    
    
    • 1
    • 2
    • 3
    • 4
    • 5

    生成条形码代码示例

    import java.awt.image.BufferedImage;
    import java.io.FileOutputStream;
    import org.jbarcode.JBarcode;
    import org.jbarcode.encode.EAN8Encoder;
    import org.jbarcode.paint.EAN8TextPainter;
    import org.jbarcode.paint.WidthCodedPainter;
    import org.jbarcode.util.ImageUtil;
    /**
    * 2022-11-01
    * @author wb
    * 支持EAN13,EAN8,UPCA,UPCE,Code 3 of 9,Codabar,Code 11,Code 93,Code 128,MSI/Plessey,Interleaved 2 of PostNet等
    */
    public class OneBarcodeUtil {
       public static void main(String[] paramArrayOfString) {
           try {
           	   //这里以EAN8为例
               JBarcode localJBarcode = new JBarcode(EAN8Encoder.getInstance(),WidthCodedPainter.getInstance(),EAN8TextPainter.getInstance());
               String str = "2219644";
               BufferedImage localBufferedImage = localJBarcode.createBarcode(str);
               saveToJPEG(localBufferedImage,"EAN8.jpeg");
           }
           catch (Exception localException) {
               localException.printStackTrace();
           }
       }
       static void saveToJPEG(BufferedImage paramBufferedImage,String paramString) {
           saveToFile(paramBufferedImage,paramString,"jpeg");
       }
       static void saveToFile(BufferedImage paramBufferedImage,String paramString1,String paramString2) {
           try {
               FileOutputStream localFileOutputStream = new FileOutputStream("C:\\Users\\wb227\\Desktop\\test" + paramString1);
               ImageUtil.encodeAndWrite(paramBufferedImage,paramString2,localFileOutputStream,96,96);
               localFileOutputStream.close();
           }
           catch (Exception localException) {
               localException.printStackTrace();
           }
       }
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
  • 相关阅读:
    小玩意 - 一篇带你玩转 SpringBoot 钉钉机器人
    QTableWidget常用属性
    vue中使用wangeditor富文本编辑器
    windows 安装Linux子系统 Ubuntu 并配置python3
    JHipster数据权限使用
    【分享贴】需求变更、项目延误,项目经理应该如何应对?
    11.10
    基于安卓android微信小程序宠物交易小程序
    【无标题】
    文件上传下载
  • 原文地址:https://blog.csdn.net/qq_37195258/article/details/127631225