• 分布式系列


    单元测试OK,封装为Dubbo服务。
     

    添加依赖

    pom.xml
      <properties>
          <dubbo.version>2.5.3</dubbo.version>
          <zookeeper.version>3.3.3</zookeeper.version>
        <zookeeper.client.version>0.1</zookeeper.client.version>
      </properties>  
       ....
            <!--dubbo框架包 -->
            <dependency>
                <groupId>com.alibaba</groupId>
                <artifactId>dubbo</artifactId>
                <version>${dubbo.version}</version>
                <exclusions>
                    <exclusion>
                        <artifactId>spring</artifactId>
                        <groupId>org.springframework</groupId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>org.apache.zookeeper</groupId>
                <artifactId>zookeeper</artifactId>
                <version>${zookeeper.version}</version>
                <exclusions>
                    <exclusion>
                        <artifactId>jmxtools</artifactId>
                        <groupId>com.sun.jdmk</groupId>
                    </exclusion>
                    <exclusion>
                        <artifactId>jline</artifactId>
                        <groupId>jline</groupId>
                    </exclusion>
                    <exclusion>
                        <artifactId>jmxri</artifactId>
                        <groupId>com.sun.jmx</groupId>
                    </exclusion>
                    <exclusion>
                        <artifactId>jms</artifactId>
                        <groupId>javax.jms</groupId>
                    </exclusion>
                    <exclusion>
                        <artifactId>activation</artifactId>
                        <groupId>javax.activation</groupId>
                    </exclusion>
                    <exclusion>
                        <artifactId>mail</artifactId>
                        <groupId>javax.mail</groupId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>com.github.sgroschupf</groupId>
                <artifactId>zkclient</artifactId>
                <version>${zookeeper.client.version}</version>
            </dependency>  

    配置maven-assembly-plugin

    pom.xml
                <plugin>
                    <artifactId>maven-assembly-plugin</artifactId>
                    <configuration>
                        <descriptor>src/main/assembly/assembly.xml</descriptor>
                        <appendAssemblyId>false</appendAssemblyId>
                        <finalName>risk_blacklist_company</finalName>
                    </configuration>
                    <executions>
                        <execution>
                            <id>make-assembly</id>
                            <phase>package</phase>
                            <goals>
                                <goal>single</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>  
     
    assembly.xml
    <!--
     - Copyright 1999-2011 Alibaba Group.
     -  
     - Licensed 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.
    -->
    <assembly>
        <id>assembly</id>
        <formats>
            <format>tar.gz</format>
        </formats>
        <includeBaseDirectory>true</includeBaseDirectory>
        <fileSets>
            <fileSet>
                <directory>/src/main/bin</directory>
                <outputDirectory>bin</outputDirectory>
                <fileMode>0755</fileMode>
            </fileSet>
            <fileSet>
                <directory>src/main/resources</directory>
                <outputDirectory>conf</outputDirectory>
                <fileMode>0644</fileMode>
            </fileSet>
            <fileSet>
                <directory>src/main/resources/conf_${conf.env}</directory>
                <outputDirectory>conf</outputDirectory>
                <fileMode>0644</fileMode>
            </fileSet>
        </fileSets>
        <dependencySets>
            <dependencySet>
                <outputDirectory>lib</outputDirectory>
            </dependencySet>
        </dependencySets>
    </assembly>  
     

    打包上传

    生成tar.gz包:mvn clean package
    上传至Linux服务器
    解压缩:tar zxvf XXX.tar.gz
    如果存在相同目录,则删除目录:rm -r dir
     

    配置运行

    关注conf/dubbo.properties中参数:“dubbo.registry.address”、“dubbo.registry.port”、”dubbo.log4j.file“
     
    执行bin/start.sh
     
    查看日志logs/stdout.log等
     





  • 相关阅读:
    CSS3实现0.5px的边框
    解决nvm导致终端启动慢的问题
    解决zsh: command not found: gitk,将git路径/usr/bin/git修改为/usr/local/bin/git
    MAC之zsh终端使用nvm安装指定版本node
    解决npm包node-sass下载失败问题
    forEach中使用async await的问题
    使用module-alias别名简化CommonJS的require路径
    关系型数据库的ACID
    Node.js ORM 框架对比
    mysql字符集 utf8 和utf8mb4 的区别
  • 原文地址:https://www.cnblogs.com/feiqihang/p/4346391.html
Copyright © 2020-2023  润新知