peace唠叨

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
    2
    3
    4
    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
2
1.下载我上面的Tomcat压缩包
2.直接解压后就安装成功

3.2.打包成war文件

我的jdk8版本和jdk7版本都在之前下载的压缩文件中,请各取所需。
1.步骤:

1
2
1.打开命令窗口并cd到dubbo-admin文件夹(下载的地方)
2.执行mvn package -Dmaven.skip.test=true

打包成功会显示如下:
00
打包成功之后,就会发现dubbo-admin下多了个target文件夹,打开target文件夹,里面有两个文件:1.文件夹dubbo-admin-2.5.4-SNAPSHOT和dubbo-admin-2.5.4-SNAPSHOT.war文件。两者都可以放入Tomcat,只需要要放一个。
01

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的文件

1
2
3
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

  1. 在浏览器输入http://localhost:8080/dubbo-admin-2.5.4-SNAPSHOT/ 注意:我改了文件夹名为dubbo
    02
    7.输入密码后:启动provider和consumer测试,点击服务
    04
    05
    05
    05
    如果可以访问并且显示,可以不观看下面,如果报错下面或许会有帮助

    4.错误解决:

    4.1打包好后放入Tomcat启动报错:

    1.错误:ERROR context.ContextLoader - Context initialization failed org.springframework.beans.factory.BeanCreationException:
    2.主要原因:主要是由于jdk8不能正常运行,切换成jdk8一下的可以运行
    3.jdk8解决办法:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    修改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也行

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<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)

Peace wechat
欢迎您扫一扫上面的微信公众号,订阅我的博客!
坚持原创技术分享,您的支持将鼓励我继续创作!