本文主要讲述使用zxing 生成二维码
首先导入Maven
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>core</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>javase</artifactId>
<version>3.1.0</version>
</dependency>
/**
* 根据内容生成二维码,并上传OSS
*
* @param text 生成二维码的参数,即:扫码跳转地址,如果是动态的,需要自己拼接
* @return 返回OSS 地址
*/
public String general(String text) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
File targetFile = null;
String ossUrl= null;
try {
Map<EncodeHintType, Object> hints = new HashMap<>();
hints.put(EncodeHintType.MARGIN, 1);
log.info("生成二维码的参数:{}",text);
BitMatrix bitMat