maven一行命令引入第三方包打包的实现
作者:Java斌
在项目开发过程中,难免会用到第三方jar的时候,本文主要介绍了maven一行命令引入第三方包打包的实现,具有一定的参考价值,感兴趣的可以了解一下
1、下载jar
将jar包放到本地目录。
2、命令行安装到maven库
使用windows 的命令行将包放到本地仓库
mvn install:install-file -Dfile=D:\maven\repository\sf\SF-CSIM-EXPRESS-SDK-V2.1.7.jar -DgroupId=com.sf -DartifactId=CSIM-EXPRESS-SDK -Dversion=2.1.7 -Dpackaging=jar
3、引入到项目中
<dependency> <groupId>com.sf</groupId> <artifactId>CSIM-EXPRESS-SDK</artifactId> <version>2.1.7</version> </dependency>
这里用顺丰丰桥的代码举例,使用正常
package com.sf.csim.express.test; import java.io.UnsupportedEncodingException; import java.util.HashMap; import java.util.Map; import java.util.UUID; import com.sf.csim.express.service.CallExpressServiceTools; import com.sf.csim.express.service.HttpClientUtil; import com.sf.csim.express.service.IServiceCodeStandard; import com.sf.csim.express.service.code.ExpressServiceCodeEnum; import com.sf.csim.express.service.code.HZTServiceCodeEnum; public class TestCallExpressNewAPIService { /**丰桥新沙箱测试顾客编码 Yg4Zf06w_sxZs3A5D 校验码 3Xdk1jqeG1Xod9nUXus8Op7DNOkchTnw **/ private static final String CLIENT_CODE = ""; //此处替换为您在丰桥平台获取的顾客编码 private static final String CHECK_WORD = "";//此处替换为您在丰桥平台获取的校验码 //沙箱环境的地址 -PRO private static final String CALL_URL_BOX = "https://sfapi-sbox.sf-express.com/std/service"; //生产环境的地址 -PRO private static final String CALL_URL_PROD = "https://sfapi.sf-express.com/std/service"; public static void main(String[] args) throws UnsupportedEncodingException { /**ExpressServiceCodeEnum 对应速运类-快递APIs POSTServiceCodeEnum 对应速运类-驿站APIs YJTServiceCodeEnum 对应解决方案-医寄通APIs EPSServiceCodeEnum 对应解决方案-快递管家APIs HZTServiceCodeEnum 对应解决方案-函证通APIs 2022-2-24 新增 详情见code目录下枚举类,客户可自行修改引用的该类 **/ IServiceCodeStandard standardService = ExpressServiceCodeEnum.EXP_RECE_CREATE_ORDER; //下订单 // IServiceCodeStandard standardService = ExpressServiceCodeEnum.EXP_RECE_SEARCH_ORDER_RESP; //查订单 // IServiceCodeStandard standardService = ExpressServiceCodeEnum.EXP_RECE_UPDATE_ORDER;//订单取消 // IServiceCodeStandard standardService = ExpressServiceCodeEnum.EXP_RECE_FILTER_ORDER_BSP;//订单筛选 // IServiceCodeStandard standardService = ExpressServiceCodeEnum.EXP_RECE_SEARCH_ROUTES;//查路由 // IServiceCodeStandard standardService = ExpressServiceCodeEnum.EXP_RECE_GET_SUB_MAILNO;//子单号 // IServiceCodeStandard standardService = ExpressServiceCodeEnum.EXP_RECE_QUERY_SFWAYBILL;//查运费 // IServiceCodeStandard standardService = ExpressServiceCodeEnum.EXP_RECE_REGISTER_ROUTE;//注册路由 // IServiceCodeStandard standardService = ExpressServiceCodeEnum.EXP_RECE_CREATE_REVERSE_ORDER;//退货下单 // IServiceCodeStandard standardService = ExpressServiceCodeEnum.EXP_RECE_CANCEL_REVERSE_ORDER;//退货消单 // IServiceCodeStandard standardService = ExpressServiceCodeEnum.EXP_RECE_WANTED_INTERCEPT;//截单转寄 // IServiceCodeStandard standardService = ExpressServiceCodeEnum.EXP_RECE_QUERY_DELIVERTM;//时效标准及价格查询 // IServiceCodeStandard standardService = ExpressServiceCodeEnum.COM_RECE_CLOUD_PRINT_WAYBILLS;//面单打印 // IServiceCodeStandard standardService = ExpressServiceCodeEnum.EXP_RECE_UPLOAD_ROUTE;//路由上传 // IServiceCodeStandard standardService = ExpressServiceCodeEnum.EXP_RECE_SEARCH_PROMITM;//预计派送时间查询 // IServiceCodeStandard standardService = ExpressServiceCodeEnum.EXP_EXCE_CHECK_PICKUP_TIME;//揽件服务时间查询 // IServiceCodeStandard standardService = ExpressServiceCodeEnum.EXP_RECE_VALIDATE_WAYBILLNO;//运单号合法性校验 CallExpressServiceTools tools=CallExpressServiceTools.getInstance(); // set common header Map<String, String> params = new HashMap<String, String>(); String timeStamp = String.valueOf(System.currentTimeMillis()); String msgData =tools.packageMsgData(standardService); params.put("partnerID", CLIENT_CODE); // 顾客编码 ,对应丰桥上获取的clientCode params.put("requestID", UUID.randomUUID().toString().replace("-", "")); params.put("serviceCode",standardService.getCode());// 接口服务码 params.put("timestamp", timeStamp); params.put("msgData", msgData); params.put("msgDigest", tools.getMsgDigest(msgData,timeStamp,CHECK_WORD)); // System.out.println(params.get("requestID")); long startTime = System.currentTimeMillis(); // System.out.println("====调用请求:" + params.get("msgData")); System.out.println("====调用实际请求:" + params); String result = HttpClientUtil.post(CALL_URL_BOX, params); System.out.println("====调用丰桥的接口服务代码:" + String.valueOf(standardService.getCode()) + " 接口耗时:"+ String.valueOf(System.currentTimeMillis()-startTime)+"===="); System.out.println("===调用地址 ==="+CALL_URL_BOX); System.out.println("===顾客编码 ==="+CLIENT_CODE); System.out.println("===返回结果:" +result); } }
到此这篇关于maven一行命令引入第三方包打包的实现的文章就介绍到这了,更多相关maven 第三方包打包内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!