首页 > 编程知识 正文

gitlab拉取代码到本地idea,外卖优惠

时间:2023-05-03 10:50:04 阅读:107285 作者:3665

从0开始制作外卖侠优惠券系统之二.1—在将clientid和clientSecret填入配置文件之前的文章中,我们提到了clientid和clientSecret。 两个东西都写在方法上。 也就是说,以后每次写一个方法都需要写这些重复的代码,所以要提高代码的可读性。 需要将这些写在配置文件中。

将clientId和clientSecret添加到application.propertise文件中

#多播配置信息pddClientId=pddClientSecret=2.在控制器上使用@value("${}”)获取变量并定义相应的专用变量赋值。

publicclasspopcontroller { @ value (' $ { PDD clientid } ) private String pddClientId; @value((${pddclientsecret} ) private String pddClientSecret; @ request mapping (/getpdgoodscats ) publicstringgetpdgoodscats (requestparamintcatid ) string clientid=pddclientid stid popclientclient=new pop http client (clientid,clientSecret ); pdgoodscatsgetrequestrequest=newpdgoodscatsgetrequest (; request.setparentcatId((long ) catid; pdgoodscatsgetresponseresponse=null; try { response=client.sync invoke (request ); }catch(exceptione ) { e.printStackTrace ); } system.out.println (JSON util.transfertojson ) response ); returnjsonutil.transfertojson (response ); }3.然后测试,完成。

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。