Skip to content

Commit

Permalink
使用spring boot进行改造,可以不依赖tomcat,使用java -jar zkWeb-V1.1.jar即可运行;
Browse files Browse the repository at this point in the history
增加了浏览器图标
  • Loading branch information
zhitom committed Sep 7, 2018
1 parent c582c63 commit 023d65f
Show file tree
Hide file tree
Showing 9 changed files with 263 additions and 34 deletions.
22 changes: 20 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
## zkWeb-en

zkWeb is zookeeper web to manager and monitor zookeeper cluster with builtin H2 database.This is based on TaoBao God(yasenagat)'s zkWeb code,and have a big upgrade and modification,It can put war-file to tomcat and execute it!
zkWeb is zookeeper web to manager and monitor zookeeper cluster with builtin H2 database.This is based on TaoBao God(yasenagat)'s zkWeb code,and have a big upgrade and modification,It can run as two methods:

1. put <war-file> to tomcat and execute it!
2. java -jar <jar-file> to execute it!

### old zkWeb code address

Expand All @@ -15,9 +18,15 @@ yasenagat-zkweb svn: [http://code.taobao.org/svn/zkweb/](http://code.taobao.org/
- Add zookeeper cluster's state-monitor function,and use four-word cmd to get state infomation
- Add zookeeper loop-check connect state
- Front-end web add i18n Internationalization plugin,Support english and zh_CN,and server-end data don't added this.
- Upgrade to use spring boot 2
- Add favicon.ico
- Todo: jsp -> Thymeleaf

## zkWeb-zh_CN
zookeeper web管理和监控界面,使用内置的H2数据库,此版本基于淘宝大神yasenagat的zkWeb源码基础之上进行了大幅升级和修改,直接将war包放入tomcat即可运行!
zookeeper web管理和监控界面,使用内置的H2数据库,此版本基于淘宝大神yasenagat的zkWeb源码基础之上进行了大幅升级和修改,有两种运行方式:

1. 直接将war包放入tomcat即可运行!
2. 直接运行: java -jar <jar-file>

### 旧zkWeb源码地址

Expand All @@ -32,12 +41,21 @@ yasenagat-zkweb svn: [http://code.taobao.org/svn/zkweb/](http://code.taobao.org/
- 增加zk集群状态的监控功能,使用了四字命令获取监控信息
- 增加zk集群自动检测连接状态功能
- 前端web增加i18n国际化插件,支持界面英文展示,注:服务端数据未支持国际化。
- 使用spring boot 2升级改造,可以不依赖tomcat
- 增加了浏览器图标favicon.ico
- Todo: jsp -> Thymeleaf

### screen snapshot

connected: [https://user-images.githubusercontent.com/2204457/41921088-a39f7856-7994-11e8-8620-90cd81dc33ce.png](https://user-images.githubusercontent.com/2204457/41921088-a39f7856-7994-11e8-8620-90cd81dc33ce.png "connected")

disconnected: [https://user-images.githubusercontent.com/2204457/41921099-a9d53620-7994-11e8-868c-1da341334184.png](https://user-images.githubusercontent.com/2204457/41921099-a9d53620-7994-11e8-868c-1da341334184.png "disconnected")

## spring boot修改备注

- 打jar包,webapp/resources无法访问,需修改代码addResourceHandlers:
- `registry.addResourceHandler("/resources/**").addResourceLocations("classpath:/resources/",
"classpath:/META-INF/resources/webapp/resources/");`

- 打war包,webapp/resources被默认打包到根目录下导致无法访问,需要打包到WEB-INF/classes/resources

11 changes: 2 additions & 9 deletions pom-jar.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<groupId>com.yasenagat.zkweb</groupId>
<artifactId>zkWeb</artifactId>
<packaging>jar</packaging>
<version>v1.1</version>
<version>v1.2</version>

<name>zkWeb</name>
<url>https://github.com/zhitom/zkweb</url>
Expand Down Expand Up @@ -134,14 +134,7 @@
<groupId>com.fasterxml.jackson.jr</groupId>
<artifactId>jackson-jr-all</artifactId>
</dependency>
<!-- servlet -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>3.0-alpha-1</version>
<!-- <scope>provided</scope> -->
</dependency>


<!-- JSP依赖 必需使用,内置的tomcat不支持jsp-->
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
Expand Down
34 changes: 26 additions & 8 deletions pom-tomcat.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<groupId>com.yasenagat.zkweb</groupId>
<artifactId>zkWeb</artifactId>
<packaging>war</packaging>
<version>v1.1</version>
<version>v1.2</version>

<name>zkWeb</name>
<url>https://github.com/zhitom/zkweb</url>
Expand All @@ -29,12 +29,30 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!-- <plugin> -->
<!-- <artifactId>maven-war-plugin</artifactId> -->
<!-- <version>3.2.2</version> -->
<!-- <configuration> -->
<!-- </configuration> -->
<!-- </plugin> -->
<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<!-- 从target打成war包时的过滤,基准目录是target/zkWeb-v1.1 下面已经过滤了,这里无需再次过滤-->
<!-- <packagingExcludes>resources/**</packagingExcludes> -->
<!-- 从target打成war包时的过滤 ,基准目录是${basedir}/src/main/webapp -->
<warSourceExcludes>resources/**</warSourceExcludes>
<webResources>
<!-- <resource> -->
<!-- <directory>src/main/resources/config/${package.environment}</directory> -->
<!-- <targetPath>WEB-INF/classes/config</targetPath> -->
<!-- <filtering>true</filtering> -->
<!-- </resource> -->
<resource>
<directory>${basedir}/src/main/webapp/resources</directory>
<!--注意此次必须要放在此目录下才能被访问到jsp-->
<targetPath>WEB-INF/classes/resources/</targetPath>
<includes>
<include>**/**</include>
</includes>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
Expand Down Expand Up @@ -113,7 +131,7 @@
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>3.0-alpha-1</version>
<!-- <scope>provided</scope> -->
<scope>provided</scope>
</dependency>

<!-- JSP依赖 -->
Expand Down
199 changes: 199 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.yasenagat.zkweb</groupId>
<artifactId>zkWeb</artifactId>
<packaging>jar</packaging>
<version>v1.2</version>

<name>zkWeb</name>
<url>https://github.com/zhitom/zkweb</url>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.2.RELEASE</version>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java-version>1.8</java-version>
<org.springframework-version>5.0.5.RELEASE</org.springframework-version>
<org.aspectj-version>1.9.1</org.aspectj-version>
<org.slf4j-version>1.7.25</org.slf4j-version>
<jackson.version>2.9.6</jackson.version>
</properties>

<build>
<resources>
<resource>
<directory>${basedir}/src/main/webapp</directory>
<!--注意此次必须要放在此目录下才能被访问到-->
<targetPath>META-INF/resources/webapp</targetPath>
<excludes>
<exclude>WEB-INF/**</exclude>
</excludes>
<includes>
<include>**/**</include>
</includes>
</resource>
<resource>
<directory>${basedir}/src/main/webapp/WEB-INF</directory>
<!--注意此次必须要放在此目录下才能被访问到jsp-->
<targetPath>/WEB-INF/</targetPath>
<includes>
<include>**/**</include>
</includes>
</resource>
<resource>
<directory>${basedir}/src/main/resources</directory>
<includes>
<include>**/**</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!-- <plugin> -->
<!-- <artifactId>maven-war-plugin</artifactId> -->
<!-- <version>3.2.2</version> -->
<!-- <configuration> -->
<!-- </configuration> -->
<!-- </plugin> -->
</plugins>
</build>
<dependencies>
<!-- <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starters</artifactId>
<version>2.0.2.RELEASE</version> <type>pom</type> </dependency> -->
<!-- Spring -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- <dependency> -->
<!-- <groupId>org.springframework.boot</groupId> -->
<!-- <artifactId>spring-boot-starter-data-jpa</artifactId> -->
<!-- </dependency> -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional> <!-- 这个需要为 true 热部署才有效 -->
</dependency>
<!-- <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</dependency> -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<!-- <dependency> -->
<!-- <groupId>org.springframework</groupId> -->
<!-- <artifactId>spring-webflux</artifactId> -->
<!-- </dependency> -->
<!-- <dependency> -->
<!-- <groupId>org.springframework.data</groupId> -->
<!-- <artifactId>spring-data-couchbase</artifactId> -->
<!-- </dependency> -->
<!-- <dependency> -->
<!-- <groupId>org.springframework.hateoas</groupId> -->
<!-- <artifactId>spring-hateoas</artifactId> -->
<!-- </dependency> -->
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-jdbc</artifactId>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
</dependency>
<!-- <dependency> -->
<!-- <groupId>org.apache.tomcat</groupId> -->
<!-- <artifactId>tomcat-annotations-api</artifactId> -->
<!-- </dependency> -->

<!-- Logging -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<!-- <scope>runtime</scope> -->
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.jr</groupId>
<artifactId>jackson-jr-all</artifactId>
</dependency>

<!-- JSP依赖 必需使用,内置的tomcat不支持jsp-->
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<!-- <scope>provided</scope> -->
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>

<!-- Zookeeper -->
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>3.4.12</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<!-- <scope>runtime</scope> -->
<!-- <version>1.4.197</version> -->
</dependency>
<dependency>
<groupId>commons-dbutils</groupId>
<artifactId>commons-dbutils</artifactId>
<version>1.7</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>23.0</version>
</dependency>

<dependency>
<groupId>com.mchange</groupId>
<artifactId>c3p0</artifactId>
<version>0.9.5.2</version>
</dependency>

<!-- https://mvnrepository.com/artifact/com.mchange/mchange-commons-java -->
<dependency>
<groupId>com.mchange</groupId>
<artifactId>mchange-commons-java</artifactId>
<version>0.2.15</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

</project>
1 change: 1 addition & 0 deletions src/main/java/com/yasenagat/zkweb/web/ZkController.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public String queryzNodeInfo(
}
} catch (Exception e) {
e.printStackTrace();
log.info("cacheId[{}] : {}",cacheId,"Disconnected Or Exception");
}

return exmsg;
Expand Down
14 changes: 0 additions & 14 deletions src/main/resources/application-local.yml
Original file line number Diff line number Diff line change
@@ -1,14 +0,0 @@
logging:
config: classpath:logback-zkweb.xml
spring:
h2:
console:
enabled: 'true'
path: /console
settings:
trace: false
web-allow-others: 'true'
jta:
enabled: false
hateoas:
use-hal-as-default-json-media-type: 'false'
13 changes: 13 additions & 0 deletions src/main/resources/application.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
#
logging:
config: classpath:logback-zkweb.xml
spring:
h2:
console:
enabled: 'true'
path: /console
settings:
trace: false
web-allow-others: 'true'
jta:
enabled: false
hateoas:
use-hal-as-default-json-media-type: 'false'
http:
encoding:
force: true
Expand Down
3 changes: 2 additions & 1 deletion src/main/webapp/WEB-INF/views/head.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
<!-- <meta id="i18n_pagename" content="strings"> -->
<link rel="stylesheet" type="text/css" href="resources/easyui/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="resources/easyui/themes/icon.css">

<link rel="shortcut icon" href="resources/favicon.ico"/>
<link rel="bookmark" href="resources/favicon.ico"/>
<script type="text/javascript" src="resources/easyui/jquery.min.js"></script>
<script type="text/javascript" src="resources/easyui/jquery.easyui.min.js"></script>
<!-- <script type="text/javascript" src="resources/easyui/locale/easyui-lang-zh_CN.js"></script> -->
Expand Down
Binary file added src/main/webapp/resources/favicon.ico
Binary file not shown.

0 comments on commit 023d65f

Please sign in to comment.