dubbo服务提供者的Maven构建流程

本文介绍了一个具体的Maven打包过程及Dubbo服务的启动流程。通过使用Maven Assembly插件,根据assembly.xml配置文件,将指定目录的文件复制并打包成tar.gz格式。此外,还详细介绍了如何通过打包后的bin目录下的脚本来启动Dubbo服务。
整个流程分为【打包流程】和【启动流程】


【打包流程】:
=============================
=============================================

采用
cd/d  %~dp0
mvn assembly:assembly
进行编译打包。
=====================================
之后 这个命令会找到 pom.xml
pom.xml内容中assembly打包配置如下:
<build>
                         <plugins>
                                     <plugin>
                                                 <artifactId> maven-assembly-plugin</artifactId >
                <configuration>
                    <descriptor> src/main/assembly/assembly.xml</descriptor
                </configuration>
                <executions>
                                                             <execution>
                                                                         <id> make-assembly</id >
                                                                         <phase> package</ phase>
                                                                         <goals>
                                                                                     <goal> single</ goal>
                                                                         </goals>
                                                             </execution>
                                                 </executions>
            </plugin>
                         </plugins>
             </build>
=========================================
之后assembly插件会根据pom.xml中的配置找到assembly.xml配置文件

pom.xml配置的参数如下图:

===============================================================
我们大概可以知道了assembly的功能其实就根据assembly.xml所配置的,把指定目录的文件复制到另一个指定的目录(不存在的文件会帮我们创建)
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/assembly/bin </directory>
            <outputDirectory> bin</ outputDirectory>
        </fileSet>
        <fileSet>
            <directory> src/main/ conf</directory>
            <outputDirectory> conf</ outputDirectory>
        </fileSet>
             </fileSets>
             <dependencySets>
                         <dependencySet>
                                     <outputDirectory> lib</ outputDirectory>
                         </dependencySet>
             </dependencySets>
</assembly>
===============================================================================

assembly执行完毕就会得到如下目录结构



整个打包流程到这里结束了

===============================
下面讲的是启动流程
【启动流程 】:

上一个打包流程的bin目录有很多启动脚本,它会对打包的文件进行操作,这些脚本依赖于打包流程的配置的目录结构。


@echo off & setlocal enabledelayedexpansion

set LIB_JARS=""
cd ..\lib
for %%i in (*) do set LIB_JARS=!LIB_JARS!;..\lib\%%i
cd ..\bin

if ""%1"" == ""debug"" goto debug
if ""%1"" == ""jmx"" goto jmx

java -Xms256m -Xmx512m -XX:MaxPermSize=64M -classpath ..\conf;%LIB_JARS% com.framework.loippi.Main
goto end

:debug
java -Xms256m -Xmx512m -XX:MaxPermSize=64M -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n -classpath ..\conf;%LIB_JARS% com.framework.loippi.Main
goto end

:jmx
java -Xms256m -Xmx512m -XX:MaxPermSize=64M -Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -classpath ..\conf;%LIB_JARS% com.framework.loippi.Main

:end
pause



上图配置中的这个main函数其实就是dubbo的container


而dubbo的main好处就是比tomcat节省资源,比我们直接用spring启动多了优雅关闭和优雅开启功能···这点官方文档有描述
另外官方的主线程等到不是用system.in.read()-__-||
而用同步锁等待




-----------------------------------------------------
另外提一下
spring container的 自动加载spring配置的目录默认是:META-INF/spring目录



附官方文档



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值