• 使用maven将GitHub上项目打包作为依赖添加


    Clone GitHub项目

    git clone https://github.com/LeeKemp/UserAgentParser
    

    将项目打成jar包,安装到maven仓库中

    D:Github ProjectUserAgentParser>mvn clean package -DSkipTests
    [INFO] Building jar: D:Github ProjectUserAgentParser	argetUserAgentParser-0.0.1.jar
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD SUCCESS
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 25.845 s
    [INFO] Finished at: 2019-04-09T14:57:39+08:00
    [INFO] Final Memory: 19M/210M
    [INFO] ------------------------------------------------------------------------
    
    D:Github ProjectUserAgentParser>mvn clean install -DSkipTests
    [INFO] Installing D:Github ProjectUserAgentParser	argetUserAgentParser-0.0.1.jar to C:Usersghc.m2
    epositorycomkumkeeUserAgentParser.0.1UserAgentParser-0.0.1.jar
    [INFO] Installing D:Github ProjectUserAgentParserpom.xml to C:Usersghc.m2
    epositorycomkumkeeUserAgentParser.0.1UserAgentParser-0.0.1.pom
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD SUCCESS
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 8.027 s
    [INFO] Finished at: 2019-04-09T14:58:51+08:00
    [INFO] Final Memory: 19M/217M
    [INFO] ------------------------------------------------------------------------
    

    在项目pom.xml中加入maven依赖

            <dependency>
                <groupId>com.kumkee</groupId>
                <artifactId>UserAgentParser</artifactId>
                <version>0.0.1</version>
            </dependency>
    

    编写junit测试类

    public class UserAgentTest {
    
        @Test
        public void test(){
            String source = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.130 Safari/537.36";
            UserAgentParser userAgentParser  = new UserAgentParser();
            UserAgent agent = userAgentParser.parse(source);
            String browser = agent.getBrowser();
            String engine = agent.getEngine();
            String engineVersion = agent.getEngineVersion();
            String os = agent.getOs();
            String platform = agent.getPlatform();
            System.out.println(browser + " , "+ engine + " , "+ engineVersion + " , "+ os + " , "+ platform);
        }
    }
    
  • 相关阅读:
    python -m pip install captcha --user
    用隐马尔可夫模型做基因预测
    爬取知乎如何通俗易懂地解释「协方差」与「相关系数」的概念?
    梯度弥散与梯度爆炸
    CIFAR-10数据集图像分类【PCA+基于最小错误率的贝叶斯决策】
    CIFAR-10 dataset 的下载与使用
    JMeter Don't use GUI mode for load testing!
    JMeter5.0版本安装及配置
    POSTMAN之断言
    PLSQL基础使用
  • 原文地址:https://www.cnblogs.com/wangyi666/p/10677011.html
Copyright © 2020-2023  润新知