最近运行用jhipster生成的一个工程,默认是
工程默认启动方法是指定配置文件编译成jar运行
./mvnw -Pprod clean verify
java -jar target/*.jar
因为开发环境默认的是运行test,只要指定
spring.profiles.active=prod
即可再开发环境直接运行
另外查看test和prod运行发现api页面链接区别,得知是只要
spring.profiles.include=swagger
即可有api页面
启动jar命令可以指定特定配置文件 java -jar -Dspring.profiles.active=dev
另一种更巧妙是另外指定配置文件路径 java -jar --spring.config.location=/home/app/config/
------------------------
另外测试一个文件上传接口发现如果是单文件上传,单文件参数不能为空,为了文件为空,只要把文件改为文件列表即可为空
api.yml
formdata时 file类型默认不可为空,想为空改为array
/expert/save_expert:
post:
tags:
- expert
summary: save expert
description: save expert to expertLibrary
requestBody:
content:
multipart/form-data:
schema:
type: object
properties:
expertLibraryDataJson:
type: string
file:
type: array
items:
type: string
format: binary
responses:
'200':
description: successful operation
content:
application/json:
schema:
$ref: '#/components/schemas/genericResponse'
生成java代码参数就是
default ResponseEntity<GenericResponse> expertSaveExpertPost(@ApiParam(value = "") @RequestPart(value="expertLibraryDataJson", required=false) String expertLibraryDataJson,@ApiParam(value = "") @Valid @RequestPart(value = "file") List<MultipartFile> file)