dubbo-admian的打包和平臺搭建


本文簡單介紹下dubbo-admin的搭建過程,包括dubbo-admin的打包細節,以及在打包過程中jdk8的一些坑的解決。


全部代碼下載:Github鏈接:github鏈接,點擊驚喜;寫文章不易,歡迎大傢采我的文章,以及給出有用的評論,當然大傢也可以關註一下我的github;多謝;


1.dubbo-admin介紹:


dubbo-admin從名字可知就是對dubbo進行管理,主要內容包括路由規則,動態配置,服務降級,訪問控制,權重調整,負載均衡,等管理功能。

dubbo的介紹和使用鏈接


2.下載地址:



  1. 官網地址:

    https://github.com/alibaba/dubbo

  2. 我的地址:有修改pom.xml文件方便jdk8打包

    tomcat和maven安裝下載:http://download.csdn.net/detail/peace1213/9645188

    dubbo-admin配套下載:http://download.csdn.net/detail/peace1213/9645191


3.打包dubbo-admin工程為war


打包其實就是使用maven將dubbo-admin工程變為war可以被Tomact使用的文件。


3.1.maven和Tomcat安裝:


1.maven安裝:


1.下載我上面的maven軟件
2.然後解壓到特定目錄:apache-maven-3.3.3
3.在path後面追加環境變量:E:\Program Files\eclipse\apache-maven-3.3.3\bin(註意:這是我的地址)
4.測試:在命令窗口下輸入:mvn

2.Tomcat安裝:


1.下載我上面的Tomcat壓縮包
2.直接解壓後就安裝成功

3.2.打包成war文件


我的jdk8版本和jdk7版本都在之前下載的壓縮文件中,請各取所需。

1.步驟:


1.打開命令窗口並cd到dubbo-admin文件夾(下載的地方)
2.執行mvn package -Dmaven.skip.test=true

打包成功會顯示如下:



打包成功之後,就會發現dubbo-admin下多瞭個target文件夾,打開target文件夾,裡面有兩個文件:1.文件夾dubbo-admin-2.5.4-SNAPSHOT和dubbo-admin-2.5.4-SNAPSHOT.war文件。兩者都可以放入Tomcat,隻需要要放一個。


3.3調試與運行:


1.啟動ZooKeeperZooKeeper環境搭建

2.將打包後的文件dubbo-admin-2.5.4-SNAPSHOT.war或者文件夾拷貝到Tomcat的webapps

3.然後到Tomcat的bin目錄下面雙擊startup.bat,啟動後再點擊shutdown.bat停止

4.修改webapps下的dubbo-admin-2.5.4-SNAPSHOT/WEB-INF/dubbo.properties的文件


dubbo.registry.address=zookeeper://127.0.0.1:2181##zk地址
dubbo.admin.root.password=root##root密碼
dubbo.admin.guest.password=guest##guest密碼

5.到Tomcat的bin目錄下面雙擊startup.bat

6. 在瀏覽器輸入http://localhost:8080/dubbo-admin-2.5.4-SNAPSHOT/ 註意:我改瞭文件夾名為dubbo



7.輸入密碼後:啟動provider和consumer測試,點擊服務









如果可以訪問並且顯示,可以不觀看下面,如果報錯下面或許會有幫助


4.錯誤解決:


4.1打包好後放入Tomcat啟動報錯:


1.錯誤:ERROR context.ContextLoader - Context initialization failed org.springframework.beans.factory.BeanCreationException:

2.主要原因:主要是由於jdk8不能正常運行,切換成jdk8一下的可以運行

3.jdk8解決辦法:


修改pom.xml文件
1、webx的依賴改為3.1.6版;

<dependency>
<groupId>com.alibaba.citrus</groupId>
<artifactId>citrus-webx-all</artifactId>
<version>3.1.6</version>
</dependency>
2、添加velocity的依賴,我用瞭1.7;

<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity</artifactId>
<version>1.7</version>
</dependency>
3、對依賴項dubbo添加exclusion,避免引入舊spring

<dependency>
<groupId>com.alibaba</groupId>
<artifactId>dubbo</artifactId>
<version>${project.parent.version}</version>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
</exclusion>
</exclusions>
</dependency>
參考於:https://github.com/alibaba/dubbo/issues/50

4.2打包時Maven依賴找不到


1.錯誤:[ERROR] Failed to execute goal on project dubbo-common: Could not resolve dependencies for project

2.原因:dubbo-admin工程下pom.xml中有些jar包不能被公網訪問到

3.解決辦法:

1.根據報的依賴錯修改version

2.下載相應的jar包放到本地倉庫

3.參考網址:https://github.com/alibaba/dubbo/issues/22


4.3我的pom.xml文件


這個文件可以被正常打包,jdk8也行


<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.alibaba</groupId>
<artifactId>dubbo-parent</artifactId>
<version>2.5.4-SNAPSHOT</version>
</parent>
<artifactId>dubbo-admin</artifactId>
<packaging>war</packaging>
<name>${project.artifactId}</name>
<description>The admin module of dubbo project</description>
<properties>
<wtpversion>1.5</wtpversion>
<wtpContextName>/</wtpContextName>
<eclipse.useProjectReferences>false</eclipse.useProjectReferences>
<skip_maven_deploy>false</skip_maven_deploy>
</properties>
<dependencies>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>dubbo</artifactId>
<version>2.5.3</version>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.alibaba.citrus</groupId>
<artifactId>citrus-webx-all</artifactId>
<version>3.1.6</version>
</dependency>
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.netty</groupId>
<artifactId>netty</artifactId>
</dependency>
<dependency>
<groupId>org.apache.mina</groupId>
<artifactId>mina-core</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.grizzly</groupId>
<artifactId>grizzly-core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
</dependency>
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
</dependency>
<dependency>
<groupId>org.apache.bsf</groupId>
<artifactId>bsf-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
</dependency>
<dependency>
<groupId>com.github.sgroschupf</groupId>
<artifactId>zkclient</artifactId>
</dependency>
<dependency>
<groupId>com.netflix.curator</groupId>
<artifactId>curator-framework</artifactId>
</dependency>
<dependency>
<groupId>com.googlecode.xmemcached</groupId>
<artifactId>xmemcached</artifactId>
</dependency>
<dependency>
<groupId>org.apache.thrift</groupId>
<artifactId>libthrift</artifactId>
</dependency>
<dependency>
<groupId>com.caucho</groupId>
<artifactId>hessian</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
</dependency>
<dependency>
<groupId>javax.cache</groupId>
<artifactId>cache-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity</artifactId>
<version>1.7</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>${jetty_version}</version>
<configuration>
<contextPath>/</contextPath>
<scanIntervalSeconds>10</scanIntervalSeconds>
<connectors>
<connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
<port>8080</port>
<maxIdleTime>60000</maxIdleTime>
</connector>
</connectors>
</configuration>
</plugin>
</plugins>
</build>
</project>

本文來自伊豚(blog.wpeace.cn)

0 個評論

要回覆文章請先登錄註冊