开发环境
- JDK:java8
- IDE:IDEA
- 项目框架:SpringBoot
项目配置
- application.yml配置
server:
port: 6389
ssl:
key-store: .keystore
key-store-type: JKS
key-alias: alias
key-store-password: xxxxxxxx
spring:
datasource:
driver-class-name: com.mysql.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/xxxxxxx?useUnicode=true&characterEncoding=utf8&useSSL=false
username: XXXXXX
password: XXXXXX
# password: root
jpa:
hibernate:
ddl-auto: update
show-sql: true
logging:
path: /opt/modules/logs/qrcode/qrcode.log
file:
imageWidth: 80 #二维码logo的宽度
imageHeight: 80 #二维码logo的高度
QRCODE_SIZE: 400 #二维码尺寸
logoImagePath: /opt/modules/qrcode/logo/logo.png #二维码logo路径
# logoImagePath: D:/data/qrcode/logo.png #二维码logo路径
qrFilePath: /opt/modules/qrcode/ #生成二维码路径
# qrFilePath: D:/data/qrcode/ #生成二维码路径
imagesPath: file:/opt/modules/qrcode/ # 二维码图片映射路径
# imagesPath: file:D:/data/qrcode/ # 二维码图片映射路径
imageReturnPath: /images/**
- 静态资源映射(图片)
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
/**
* Created by Tomthy on 2018/11/21.
*/
@Configuration
public class WebMvcConf extends WebMvcConfigurerAdapter {
@Value("${file.imageReturnPath}")
private String imageReturnPath;
@Value("${file.imagesPath}")
private String imagesPath;
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
//imageReturnPath:映射前缀,imagesPath:图片映射路径
registry.addResourceHandler(imageReturnPath).addResourceLocations(imagesPath);
}
}
-
本地图片地址
-
url请求查询
服务器与本地使用情况相同