<!--生成二维码--> <dependency> <groupId>com.google.zxing</groupId> <artifactId>core</artifactId> <version>3.3.0</version> </dependency> <dependency> <groupId>com.google.zxing</groupId> <artifactId>javase</artifactId> <version>3.3.0</version> </dependency>
这里是我查需求的时候查到的资料并不完善,请忽略写法和其他东西重点放在功能点上, 这个还是有很多局限性的东西,比如说二维码中的内容不能超过125字节,使用微信扫出来的内容只能是字符串 和 微信的名片(写法百度上有很多) 并不适用于我现在的需求只是在这里做个记录 @SneakyThrows public static void test() { QRCodeWriter qrCodeWriter = new QRCodeWriter(); String codePath = "C:\\Users\\hw\\Desktop"+"\\"+"code"+".png"; BitMatrix bitMatrix = qrCodeWriter.encode("123", BarcodeFormat.QR_CODE, 300, 300); Path path = FileSystems.getDefault().getPath(codePath); MatrixToImageWriter.writeToPath(bitMatrix,"PNG", path); }