本文簡單介紹下dubbo-admin的搭建過程,包括dubbo-admin的打包細節,以及在打包過程中jdk8的一些坑的解決。
全部代碼下載:Github鏈接:github鏈接,點擊驚喜;寫文章不易,歡迎大家采我的文章,以及給出有用的評論,當然大家也可以關注一下我的github;多謝;
dubbo-admin從名字可知就是對dubbo進行管理,主要內容包括路由規則,動態配置,服務降級,訪問控制,權重調整,負載均衡,等管理功能。 dubbo的介紹和使用鏈接
打包其實就是使用maven將dubbo-admin工程變為war可以被Tomact使用的文件。
1.maven安裝:
1.下載我上面的maven軟件2.然后解壓到特定目錄:apache-maven-3.3.33.在path后面追加環境變量:E:/PRogram Files/eclipse/apache-maven-3.3.3/bin(注意:這是我的地址)4.測試:在命令窗口下輸入:mvn2.Tomcat安裝:
1.下載我上面的Tomcat壓縮包2.直接解壓后就安裝成功我的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,只需要要放一個。 
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測試,點擊服務
如果可以訪問并且顯示,可以不觀看下面,如果報錯下面或許會有幫助
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/501.錯誤:[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
這個文件可以被正常打包,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)
新聞熱點
疑難解答