金蝶容器Apusic中重新部署war包

1 简介

由于当前的项目platform需要部署在192.168.1.92上,因此在添加了新的功能之后,需要重新为项目制作jar包和重新把项目部署在金蝶容器中,在此简要的把部署的过程总结如下。
注意:platform项目默认部署的在192.168.1.92上,并且端口为8080,由于项目基于SpringBoot,因此在默认情况下访问接口时是需要加入项目名称platform的,但为了之前接口的一致性,把platform制作成ROOT项目,默认访问的接口不需要添加
访问接口url类似如下:

http://192.168.1.92:8080/platform/api/resource/acsDevice/allAcsDevices

2 制作war包

2.1 pom.xml

<?xml version="1.0" encoding="UTF-8"?>
    <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>
        <parent>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-parent</artifactId>
            <version>2.0.3.RELEASE</version>
            <relativePath/> <!-- lookup parent from repository -->
        </parent>
        <groupId>com.cetc52</groupId>
        <artifactId>platform</artifactId>
        <version>V1.0</version>
        <name>platform</name>
        <packaging>war</packaging>
    
        <description>Support project for 28</description>
    
        <properties>
            <java.version>1.8</java.version>
        </properties>
    
        <dependencies></dependencies>
    
        <build>
            **<finalName>platform</finalName>**
            <plugins>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>${maven-compiler-plugin.version}</version>
                    <configuration>
                        <source>1.8</source>
                        <target>1.8</target>
                        <skip>true</skip>
                        <encoding>UTF-8</encoding>
                        <compilerArguments>
                            <extdirs>${project.basedir}/src/main/resources/lib</extdirs>
                            <!--extdirs>lib</extdirs>-->
                        </compilerArguments>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>3.1.0</version>
                    <configuration>
                        <webResources>
                            <resource>
                                <directory>src/main/resources/lib/</directory>
                                <targetPath>WEB-INF/lib/</targetPath>
                                <includes>
                                    <include>**/*.jar</include>
                                </includes>
                            </resource>
                        </webResources>
                        <failOnMissingWebXml>false</failOnMissingWebXml>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    
    </project>

2.2 检测application.properties

当前application.properties配置文件如下:

 #server.port=9555
    visitor.eventUploadUrl=http://192.168.1.92:10000/zhyqts/services/rest/monitor/visitorEvent
    isc.eventUploadUrl=http://192.168.1.92:10000/yqsjcj/services/rest/rest/get
    isc.testUrl=http://192.168.1.92:10000/zhyqts/services/rest/monitor/action
    isc.gatewayUrl=http://192.168.1.51:8080/JRYX/api/doorCaution
    
    logging.file=mylog.log
    
    tomcat.ip=192.168.1.92
    tomcat.port=8080
    tomcat.projectName=
    
    #config for lieying service
    lieying.ip=192.168.1.117
    lieying.address=https://${lieying.ip}:443
    lieying.uploadAddress=http://192.168.1.92:10000
    lieying.loginName=admin
    lieying.passwd=hik12345
    
    #config for lianpu service
    lianpu.ip=192.168.1.112
    lianpu.address=https://${lianpu.ip}:443
    lianpu.uploadAddress=http://192.168.1.92:10000
    lianpu.loginName=admin
    lianpu.passwd=hik12345+
    
    #config for iSecureCenter
    iSecureCenter.host=192.168.1.111
    iSecureCenter.appkey=20644300
    iSecureCenter.appsecret=uBvol0HInjIc8oOJoT3a

2.3 配置含义

3 步骤

3.1 前提

确保当前项目所在的域配置文件中开启的端口为8080,该配置文件路径如下:
/usr/local/yyzc/52-project/AAS-V9.0_2019-1-7/domains/mydomain/config/ apusic.conf
在配置文件中apusic.conf中,关注参数

 <SERVICE
        CLASS="com.apusic.net.Muxer"
        >
        <ATTRIBUTE NAME="Port" VALUE="8080"/>
        <ATTRIBUTE NAME="Backlog" VALUE="1024"/>
        <ATTRIBUTE NAME="Timeout" VALUE="30"/>
        <ATTRIBUTE NAME="LookAheadTimeout" VALUE="30"/>
        <ATTRIBUTE NAME="MaxWaitingClients" VALUE="200"/>
        <ATTRIBUTE NAME="WaitingClientTimeout" VALUE="5"/>
        <ATTRIBUTE NAME="SSLEnabled" VALUE="False"/>
        <ATTRIBUTE NAME="SecurePort" VALUE="6889"/>
        <ATTRIBUTE NAME="KeyStore" VALUE="config/sslserver"/>
        <ATTRIBUTE NAME="KeyStorePassword" VALUE="keypass"/>
        <ATTRIBUTE NAME="KeyPassword" VALUE="keypass"/>
    </SERVICE>

可以确定Port对应的值为8080,并且当前系统所在的ip与配置文件中application.properties中的tomcat.ip保持一致。

3.2 停止platform项目

3.2.1 切换至applications目录

首先要切换目录到当前项目所在的applications目录中。

    [Unauthorized System] root@lccy-os:~# cd /usr/local/yyzc/52-project/AAS-V9.0_2019-1-7/domains/mydomain/applications
    
    [Note] System unauthorized, Please contact the system supplier.
    
    [Unauthorized System] root@lccy-os:/usr/local/yyzc/52-project/AAS-V9.0_2019-1-7/domains/mydomain/applications#

3.2.2 stopapusic目录停止项目

使用相对路径执行命令停止当前项目所在:

[Unauthorized System] root@lccy-os:/usr/local/yyzc/52-project/AAS-V9.0_2019-1-7/domains/mydomain/applications# ../bin/stopapusic

需要注意的是,在金蝶容器中执行了上述的停止命令,虽然执行成功了,但程序其实并未执行成功,此时需要通过杀死进程的方式来解决该问题,可以使用

netstat –anop | grep 8080

的方式来查询进程PID

3.2.3 查询项目所在PID

3.2.3.1 netstat

[Unauthorized System] root@lccy-os:/usr/local/yyzc/52-project/AAS-V9.0_2019-1-

    7/domains/mydomain/applications# netstat -ano | grep 8080
    tcp        0      0 0.0.0.0:8080            0.0.0.0:*               LISTEN      关闭 (0.00/0/0)
    
    [Note] System unauthorized, Please contact the system supplier.
    
    [Unauthorized System] root@lccy-os:/usr/local/yyzc/52-project/AAS-V9.0_2019-1-7/domains/mydomain/applications# netstat -anop | grep 8080
    tcp        0      0 0.0.0.0:8080            0.0.0.0:*               LISTEN      3745/java        关闭 (0.00/0/0)

其中-p参数作用如下:

-p, --programs           display PID/Program name for sockets

关于netstat命令的参数内容参见如下:

[Unauthorized System] root@lccy-os:/usr/local/yyzc/52-project/AAS-V9.0_2019-1-7/domains/mydomain/applications# netstat --help
    usage: netstat [-vWeenNcCF] [<Af>] -r         netstat {-V|--version|-h|--help}
           netstat [-vWnNcaeol] [<Socket> ...]
           netstat { [-vWeenNac] -i | [-cWnNe] -M | -s }
    
            -r, --route              显示路由表
            -i, --interfaces         display interface table
            -g, --groups             display multicast group memberships
            -s, --statistics         display networking statistics (like SNMP)
            -M, --masquerade         display masqueraded connections
    
            -v, --verbose            显示详细信息
            -W, --wide               don't truncate IP addresses
            -n, --numeric            不解析名称
            --numeric-hosts          不解析主机名
            --numeric-ports          忽略端口名称
            --numeric-users          忽略用户名
            -N, --symbolic           resolve hardware names
            -e, --extend             显示更多信息
            -p, --programs           display PID/Program name for sockets
            -c, --continuous         continuous listing
    
            -l, --listening          display listening server sockets
            -a, --all, --listening   display all sockets (default: connected)
            -o, --timers             display timers
            -F, --fib                display Forwarding Information Base (default)
            -C, --cache              display routing cache instead of FIB
    
      <Socket>={-t|--tcp} {-u|--udp} {-w|--raw} {-x|--unix} --ax25 --ipx --netrom
      <AF>=Use '-6|-4' or '-A <af>' or '--<af>';默认: inet
      列出所有支持的协议:
        inet (DARPA Internet) inet6 (IPv6) ax25 (AMPR AX.25) 
        netrom (AMPR NET/ROM) ipx (Novell IPX) ddp (Appletalk DDP) 
        x25 (CCITT X.25)
3.2.3.2 lsof

也可以使用lsof命令来查看某个端口所对应的pid。lsof主要作用为list open files。

An open file may be a regular file, a directory, a block special file, a character special file, an executing text reference, a library, a stream
 or a network file (Internet socket, NFS file or UNIX domain socket.)  A specific file or all the files in a file system may be selected by path.

Instead of a formatted display, lsof will produce output that can be parsed by other programs.  See the -F, option description, and the OUTPUT FOR
OTHER PROGRAMS section for more information.

In addition to producing a single output list, lsof will run in repeat mode.  In repeat mode it will produce output, delay, then repeat the output
operation until stopped with an interrupt or quit signal.  See the +|-r [t[m<fmt>]] option description for more information.

3.2.4 使用kill杀死进程

对于如上的netstat输出,执行kill -9 3745即可保证项目停止成功

[Unauthorized System] root@lccy-os:/usr/local/yyzc/52-project/AAS-V9.0_2019-1-7/domains/mydomain/applications# kill -9 3745

3.3 拷贝运行项目

可以使用工具把制作好的platform.war包拷贝进入applications目录中。
[Unauthorized System] root@lccy-os:/usr/local/yyzc/52-project/AAS-V9.0_2019-1-7/domains/mydomain/applications# ls
platform.war
此时使用jar工具把platform.war包解压到applications目录下。
[Unauthorized System] root@lccy-os:/usr/local/yyzc/52-project/AAS-V9.0_2019-1-7/domains/mydomain/applications# jar -xf platform.war

在外部制作好war包之后,使用解压缩工具打开war包,可以看到生成了platform文件夹,其中该文件夹内容如下:
在这里插入图片描述
注意:application.properties文件即为配置文件

3.4 重启项目

3.4.1 启动项目

在当前项目下执行startapusic命令启动项目

    [Unauthorized System] root@lccy-os:/usr/local/yyzc/52-project/AAS-V9.0_2019-1-7/domains/mydomain/applications# nohup ../bin/startapusic 1> ../bin/nohup.out 2>&1 &
    [1] 28330
    
    [Note] System unauthorized, Please contact the system supplier.

此时,会在…/bin目录下生成nohup.out,其中的内容为platform项目生成的日志。
使用数据重定向技术把相关的日志打入bin目录下的nohup.out文件。
数据重定向可以将stanardout output和standard error output分别传送到其他的文件或设备区,分别使用如下的特殊字符。
在这里插入图片描述
至于>与>>符号的区别参见如下:
在这里插入图片描述
至于最后一个&符号,主要作用是直接将命令丢到后台执行。列出在后台中的任务可以通过jobs命令显示。

jobs –lrs

将后台工作拿到前台来处理则使用如下命令:

fg %jobnumber

管理后台当中的工作可以使用kill命令

kill –signal %jobnumber

其中signal为9表示立刻强制删除一个工作。
可以使用命令查看日志的内容。

[Unauthorized System] root@lccy-os:/usr/local/yyzc/52-project/AAS-V9.0_2019-1-7/domains/mydomain/applications# tail -f ../bin/nohup.out

3.4.2 杀死进程

如果执行上述的命令报错如下:

2019-04-08 21:25:06 信息 [apusic.service.Muxer-Thread 1] 侦听端口 8080
2019-04-08 21:25:06 错误 [apusic.service.Muxer-Thread 1] 启动失败
java.net.BindException: 地址已在使用
	at sun.nio.ch.Net.bind0(Native Method)
	at sun.nio.ch.Net.bind(Net.java:433)
	at sun.nio.ch.Net.bind(Net.java:425)
	at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223)
	at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
	at com.apusic.net.Muxer.createServerSocketChannel(Muxer.java:1112)
	at com.apusic.net.Muxer.startService(Muxer.java:1158)
	at com.apusic.service.Service.start(Service.java:205)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.apusic.jmx.MBeanDescriptor.invoke(MBeanDescriptor.java:546)
	at com.apusic.jmx.DynamicMBeanSupport.invoke(DynamicMBeanSupport.java:62)
	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
	at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
	at com.apusic.server.J2EEServer.start(J2EEServer.java:609)
	at com.apusic.server.J2EEServer.startup(J2EEServer.java:354)
	at com.apusic.server.Main.main(Main.java:35)

解决方式参见使用kill杀死进程

4 配置根目录

在启动项目之后,SpringBoot开发的项目默认在访问时是需要在URL中添加项目名称的,而为了减少此开发过程中引入的复杂度,需要把项目设置为金蝶容器中的ROOT项目。

4.1 登录网页

登录网页

http://192.168.1.92:8080/admin

页面如下:
在这里插入图片描述

4.2 配置项目为ROOT

登录首页,在首页/应用管理/参数配置
在这里插入图片描述
点击参数配置按钮,修改配置如下:
在这里插入图片描述
保存即可。

4.3 验证接口调用

4.3.1 Postman验证

可以在Postman中使用Get接口进行功能的验证

http://192.168.1.92:8080/api/resource/acsDevice/allAcsDevices

该接口的主要功能为获取所有门禁设备信息,结果应输出如下:

{
    "msg": "success",
    "code": "0",
    "data": {
        "list": [
            {
                "regionIndexCode": "60fa49cb-1a8e-4298-bfab-444cf6d3d565",
                "acsDevTypeCode": "201933568",
                "createTime": "2019-01-23T10:22:48.041+08:00",
                "acsDevTypeDesc": "DS-K1T604MF",
                "acsDevName": "门禁一体机1",
                "acsDevIndexCode": "2bc71153e0254f1fa737825eaa46ec0a",
                "updateTime": "2019-01-23T10:25:38.290+08:00",
                "acsDevIp": "192.168.1.103",
                "acsDevPort": "8000",
                "treatyType": "hiksdk_net"
            },
            {
                "regionIndexCode": "60fa49cb-1a8e-4298-bfab-444cf6d3d565",
                "acsDevTypeCode": "201933568",
                "createTime": "2019-01-23T10:23:22.547+08:00",
                "acsDevTypeDesc": "DS-K1T604MF",
                "acsDevName": "门禁一体机2",
                "acsDevIndexCode": "d0d6fa5c418445ef8bb4444347cea562",
                "updateTime": "2019-01-23T10:23:24.381+08:00",
                "acsDevIp": "192.168.1.104",
                "acsDevPort": "8000",
                "treatyType": "hiksdk_net"
            },
            {
                "regionIndexCode": "60fa49cb-1a8e-4298-bfab-444cf6d3d565",
                "acsDevTypeCode": "201933568",
                "createTime": "2019-04-01T17:32:08.924+08:00",
                "acsDevTypeDesc": "DS-K1T604MF",
                "acsDevName": "门禁一体机3",
                "acsDevIndexCode": "fe6012d390cb43558abf74bef0279d5e",
                "updateTime": "2019-04-01T17:32:10.886+08:00",
                "acsDevIp": "192.168.1.105",
                "acsDevPort": "8000",
                "treatyType": "hiksdk_net"
            }
        ]
    }
}

也可以在Url中直接访问该url,查看获取的结果是否正确

4.3.2 浏览器验证

在这里插入图片描述

4.4 订阅相关事件

在项目启动之后,确保执行关注事件的订阅。

POST    192.168.1.33:8080/api/eventService/eventSubscriptionByEventTypes

要传入的Body为application/json格式

{
	"eventTypes": [
                    198914,
                    197140,
                    131611,
                    131586,
                    196893,
                    197634,
                    131598,
                    198913,
                    196983,
                    131585,
                    131588,    区域入侵
                    131593,
                    131595,
                    197128,
                    197162,
                    131587,
                    197160,
                    197163,
                    197127,
                    197151,
                    131594,
                    131592,
                    199169,
                    131590,
                    131597,
                    199429,
                    198658,
                    199428
                ]
}

执行请求应返回如下结果:

    {
        "msg": "事件订阅成功",
        "code": "0"
    }

注意:当前项目环境仅关注了两类事件,一为门禁事件以19开头,另一类为监控事件,以13开头。

5 总结

文档主要是阐述war包重新部署在金蝶容器中的过程,确保海康设备智能分析服务、资源获取服务的正确运行,为智慧营区项目的演示提供良好的支撑。

6下载

金蝶容器重新部署war包过程详细阐述

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值