springboot工程启动配置文件

最近运行用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) 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值