首页 > 其他分享 >常见问题解决 --- 海康OpenAPI安全认证库的demo运行报错

常见问题解决 --- 海康OpenAPI安全认证库的demo运行报错

时间:2024-03-10 18:57:51浏览次数:16  
标签:11 常见问题 -- demo jar maven gt 报错 ndash

我要开发一个对接海康isc平台的oss的api,发现需要有海康登录库和ak、sk的配合才能完成。

在海康官方下载OpenAPI安全认证库(JAVA) V1.1.11,解压后用idea打开demo发现一对报错。

解决办法:

1.修复基本的错误。比如包名报错,应该是  package ga; 

2.修复maven依赖导入报错。首先是artemis-http-client这个依赖是海康自研的依赖包,pom中配置的源是海康内部的仓库,我们无权访问,你可以打开链接看看会提示502报错。在maven中央仓库中搜索可以发现有这个包,但是是1.1.3的旧版本,我导入旧版本会提示代码报错,因为代码有兼容性问题,必须用新版。在这里我插一句话基础常识,maven仓库有很多,最大的仓库叫做 maven中央仓库,里面放置有上万个jar包。还有其他官方提供的自己的仓库,比如spring官方自己搭建了一个maven仓库里面都是最新的spring jar包,也就是说,中央的最全但是不新,自有的最新但是不全。 这里在idea导入自己下载的jar包我知道的有三种方法,

第一种,在项目下创建一个lib文件夹,里面放置所有你要导入的库,在库上右键 作为库导入

第二种,在设置里的项目结构---模块---依赖中添加你要的库

第三种,就是离线安装到maven本地仓库中,我建议使用这种方式方便我们后期编译jar。 


要将这三个 JAR 包手动安装到本地 Maven 仓库中,你可以使用 Maven 命令 mvn install:install-file。你需要在命令中提供每个 JAR 文件的路径、groupId、artifactId、version 以及打包类型。

假设这三个 JAR 文件都在当前目录下,你可以使用以下命令将它们安装到本地 Maven 仓库中:

mvn install:install-file -Dfile=artemis-http-client-1.1.11.RELEASE.jar -DgroupId=com.hikvision.ga -DartifactId=artemis-http-client -Dversion=1.1.11.RELEASE -Dpackaging=jar mvn install:install-file -Dfile=artemis-http-client-1.1.11.RELEASE-javadoc.jar -DgroupId=com.hikvision.ga -DartifactId=artemis-http-client -Dversion=1.1.11.RELEASE -Dpackaging=javadoc mvn install:install-file -Dfile=artemis-http-client-1.1.11.RELEASE-sources.jar -DgroupId=com.hikvision.ga -DartifactId=artemis-http-client -Dversion=1.1.11.RELEASE -Dpackaging=sources  

请注意,这里的 -Dfile 参数指定了要安装的文件的路径,-DgroupId-DartifactId-Dversion-Dpackaging 参数分别指定了依赖的 groupId、artifactId、版本和打包类型。根据你的实际情况,可能需要调整这些参数的值。

安装完成后,这些依赖将被复制到本地 Maven 仓库中,并可以在你的 Maven 项目中正常引用。

 在pom文件中修改,注意版本是这个1.1.11.RELEASE

<dependency> <groupId>com.hikvision.ga</groupId> <artifactId>artemis-http-client</artifactId> <version>1.1.11.RELEASE</version> </dependency>

仓库地址要改为你的本地仓库

<repositories> <repository> <id>local-repo</id> <url>file:///D:/repository/.m2/repository</url> </repository> </repositories>

修改好后右键maven 重载

3.修改maven编译插件。官方给我的编译插件有问题,编译后的jar中没有打包进入依赖。

我注释掉原来的build标签

   <build>
        <plugins>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>3.3.0</version>
                <configuration>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                    <archive>
                        <manifest>
                            <mainClass>ga.ArtemisPostTest</mainClass> <!-- 设置入口类 -->
                        </manifest>
                    </archive>
                </configuration>
                <executions>
                    <execution>
                        <id>make-assembly</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

修改好后右键maven 重载

4.修改java环境依赖

因为你本机和项目pom中配置的java版本不一致,要改为你真实的java版本,我这里装的是java17,我要改为java17

<properties>
<javadocExecutable>${java.home}/../bin/javadoc</javadocExecutable>
<httpcomponents.version>4.5.14</httpcomponents.version>
<fastjson.version>1.2.83</fastjson.version>
<commons-lang3.version>3.12.0</commons-lang3.version>
<logback.version>1.2.11</logback.version>
<java.version>17</java.version>
</properties>

在项目结构中所有的java版本都要改为17,不在赘述

 

最终修改后的pom文件如下

<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with
  this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
  "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations
  under the License. -->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.hikvision.ga</groupId>
    <artifactId>artemis-http-client-demo</artifactId>
    <version>1.1.11</version>
    <packaging>jar</packaging>
    <name>artemis-http-client-demo</name>
    <description>hikvision open sdk</description>
    <url>hikvision-artemis-sdk</url>

    <properties>
        <javadocExecutable>${java.home}/../bin/javadoc</javadocExecutable>
        <httpcomponents.version>4.5.14</httpcomponents.version>
        <fastjson.version>1.2.83</fastjson.version>
        <commons-lang3.version>3.12.0</commons-lang3.version>
        <logback.version>1.2.11</logback.version>
        <java.version>17</java.version>
    </properties>

    <licenses>
        <license>
            <name>The Apache Software License, Version 2.0</name>
            <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
            <distribution>repo</distribution>
        </license>
    </licenses>

    <scm>
        <url></url>
    </scm>

    <developers>
        <developer>
            <name>sky-lft</name>
        </developer>
    </developers>

    <dependencies>
        <dependency>
            <groupId>com.hikvision.ga</groupId>
            <artifactId>artemis-http-client</artifactId>
            <version>1.1.11.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>${httpcomponents.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpmime</artifactId>
            <version>${httpcomponents.version}</version>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>${fastjson.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>${commons-lang3.version}</version>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-core</artifactId>
            <version>${logback.version}</version>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <version>${logback.version}</version>
        </dependency>
    </dependencies>
<!--    <build>-->
<!--        <plugins>-->
<!--            <plugin>-->
<!--                <artifactId>maven-compiler-plugin</artifactId>-->
<!--                <configuration>-->
<!--                    <source>17</source>-->
<!--                    <target>17</target>-->
<!--                    <encoding>UTF-8</encoding>-->
<!--                </configuration>-->
<!--            </plugin>-->
<!--            <plugin>-->
<!--                <groupId>org.apache.maven.plugins</groupId>-->
<!--                <artifactId>maven-source-plugin</artifactId>-->
<!--                <version>2.2.1</version>-->
<!--                <executions>-->
<!--                    <execution>-->
<!--                        <id>attach-sources</id>-->
<!--                        <goals>-->
<!--                            <goal>jar-no-fork</goal>-->
<!--                        </goals>-->
<!--                    </execution>-->
<!--                </executions>-->
<!--            </plugin>-->
<!--&lt;!&ndash;            <plugin>&ndash;&gt;-->
<!--&lt;!&ndash;                <groupId>org.apache.maven.plugins</groupId>&ndash;&gt;-->
<!--&lt;!&ndash;                <artifactId>maven-javadoc-plugin</artifactId>&ndash;&gt;-->
<!--&lt;!&ndash;                <version>2.10.3</version>&ndash;&gt;-->
<!--&lt;!&ndash;                <configuration>&ndash;&gt;-->
<!--&lt;!&ndash;                    <additionalparam>-Xdoclint:none</additionalparam>&ndash;&gt;-->
<!--&lt;!&ndash;                </configuration>&ndash;&gt;-->
<!--&lt;!&ndash;                <executions>&ndash;&gt;-->
<!--&lt;!&ndash;                    <execution>&ndash;&gt;-->
<!--&lt;!&ndash;                        <goals>&ndash;&gt;-->
<!--&lt;!&ndash;                            <goal>jar</goal>&ndash;&gt;-->
<!--&lt;!&ndash;                        </goals>&ndash;&gt;-->
<!--&lt;!&ndash;                    </execution>&ndash;&gt;-->
<!--&lt;!&ndash;                </executions>&ndash;&gt;-->
<!--&lt;!&ndash;            </plugin>&ndash;&gt;-->
<!--        </plugins>-->

<!--    </build>-->
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>3.3.0</version>
                <configuration>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                    <archive>
                        <manifest>
                            <mainClass>ga.ArtemisPostTest</mainClass> <!-- 设置入口类 -->
                        </manifest>
                    </archive>
                </configuration>
                <executions>
                    <execution>
                        <id>make-assembly</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <repositories>
        <repository>
            <id>local-repo</id>
            <url>file:///D:/repository/.m2/repository</url>
        </repository>
    </repositories>
</project>

 

标签:11,常见问题,--,demo,jar,maven,gt,报错,ndash
From: https://www.cnblogs.com/GKLBB/p/18064554

相关文章

  • WordPress:常见问题及解决方案
    解决头像不显示问题默认头像效果:Gavatar的头像在国内不能正常访问,如图:设置:把以下php代码添加到模板函数funtions.php文件中if(!function_exists('get_cravatar_url')){/***把Gravatar头像服务替换为Cravatar*@paramstring$url*@return......
  • OpenWrt之Transmission报错
    OpenWrt之Transmission报错浏览器http://192.168.1.1:9091/transmission/输入后,报错为404,具体如下:Couldn'tfindTransmission'swebinterfacefiles!修复教程:进入路由器,编辑/etc/init.d/transmission这个文件在这个文件的快结尾处,注释掉这句procd_add_jailtransmissio......
  • 记录一个报错信息:Name for argument of type [java.lang.Integer] not specified, and
    报错如下:错误复现代码如下:@GetMapping("/consumer/pay/getById/{orderId}")@Parameter(name="orderId",description="订单id",in=ParameterIn.PATH)publicRgetOrder(@PathVariableIntegerorderId){System.out.println(o......
  • 解决python导入csv文件报错
    python编码报错:UnicodeDecodeError:‘utf-8‘codeccan‘tdecodebyte0xbcinposition2:invalidstartbyt_unicodedecodeerror:'utf-8'codeccan'tdecodebyt-CSDN博客报错原因是:UnicodeDecodeError:'utf-8'codeccan'tdecodebyte0xb5in......
  • APatch常见问题解答
    常见问题解答什么是APatch?APatch是一种类似于Magisk或KernelSU的root解决方案,但APatch提供更多功能。APatch分别结合了Magisk方便易用的通过boot.img安装的方法,和KernelSU强大的内核修补能力。APatch与Magisk的区别?Magisk对启动映像中的ramdisk进行补丁,以修改init系统。而AP......
  • CompletableFuture Demo
    CompletableFutureDemo题目:有一个数据库client,从数据库中取数据A和数据B,然后求和。请使用并发的知识,尽快的完成操作。/***{@code@author:}keboom*{@code@date:}2024/3/8*{@code@description:}*/publicclassDataBaseClient{@SneakyThrowspublic......
  • flutter开发提示Flutter device daemon #1报错解决方法
    1.问题描述更新或者切换AndroidStudio时候可能会出现Flutterdevicedaemon#1问题,这个问题出现会导致AndroidStudio找不到Device设备,从而导致没有方法跑flutter项目。2.解决方法先在cmd窗口输入flutterdoctor诊断查看一下什么问题,一般出现和flutter环境有关的问题......
  • 新建数据库报错亦或者root 账号无法显示所有数据库
    NavicatPremium创建数据库报1044-Accessdeniedforuser'root'@'%'todatabase1查询权限SELECThost,user,Grant_priv,Super_privFROMmysql.user; 2、修改权限UPDATEmysql.userSETGrant_priv='Y',Super_priv='Y'WHEREUse......
  • Qt开发,报错:Error while building/deploying project untitled (kit: ....)
    1、问题描述 Qt开发,编译时,报错如下:1Cannotfindfile:F:\linux\...\Console.pro.213:49:47:进程"D:\Qt\Qt5.14.2\5.14.2\msvc2017_64\bin\qmake.exe"退出,退出代码2。3Errorwhilebuilding/deployingprojectConsole(kit:DesktopQt5.14.2MSVC201764bit)4......
  • vue3 报错解决:找不到模块或其相应的类型声明。(Vue 3 can not find module)
    当我们在引入应该组件的时候提示找不到这个组件但是项目明明就有这个物理文件报错原因:typescript只能理解.ts文件,无法理解.vue文件 这个时候我们应该这样首先原因:1、volar插件没开takeover模式去看volar插件介绍,开takeover模式2、volar未选择tyscript最新版本解决:1、......