更新时间:2024-04-30 GMT+08:00
分享

在Windows下调测springboot程序

编译并运行程序

在程序代码完成开发后,您可以在Windows环境中运行应用。本地和集群业务平面网络互通时,您可以直接在本地进行调测。在开发环境IntelliJ IDEA工程“clickhouse-rest-client-examples”中右键单击“ClickHouseApplication”,选择“Run ClickHouseApplication”运行应用程序工程。

操作步骤

  1. 在IDEA界面拷贝clickhouse-example.properties路径。右键clickhouse-example.properties文件,单击“Copy Path/Reference > Absolute Path”。

    图1 拷贝配置文件绝对路径

  2. 使用clickhouse-example.properties路径替换ClickHouseFunc.java中getProperties()方法中proPath的路径。

    图2 ClickHouseFunc.java路径替换

查看调测结果

  1. ClickHouse springboot服务启动后,通过ClickHouse样例接口触发样例代码运行,在浏览器中输入需要执行具体操作的链接,如http://localhost:8080/clickhouse/executeQuery,返回结果:
    ClickHouse springboot client runs normally.
  2. 通过ClickHouse日志获取应用运行情况,即日志文件:clickhouse-springboot-example.log

    运行clickhouse-springboot样例后,控制台显示部分运行结果如下:

    .   ____          _            __ _ _
    /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
    ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
    \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
    '  |____| .__|_| |_|_| |_\__, | / / / /
    =========|_|==============|___/=/_/_/_/
    :: Spring Boot ::                (v2.7.0)
    
    2023-02-06 17:58:22.144  INFO 20556 --- [           main] c.h.f.c.e.s.r.ClickHouseApplication      : Starting ClickHouseApplication using Java 1.8.0_181 on DESKTOP-64PQBSD with PID 20556 (D:\Code\cloudBU\sample_project\src\springboot\clickhouse-examples\clickhouse-rest-client-example\target\classes started by l00467039 in D:\Code\cloudBU\sample_project\src\springboot\clickhouse-examples\clickhouse-rest-client-example)
    2023-02-06 17:58:22.146  INFO 20556 --- [           main] c.h.f.c.e.s.r.ClickHouseApplication      : No active profile set, falling back to 1 default profile: "default"
    2023-02-06 17:58:22.815  INFO 20556 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
    2023-02-06 17:58:22.820  INFO 20556 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
    2023-02-06 17:58:22.821  INFO 20556 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.63]
    2023-02-06 17:58:22.928  INFO 20556 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
    2023-02-06 17:58:22.928  INFO 20556 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 750 ms
    2023-02-06 17:58:23.175  INFO 20556 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
    2023-02-06 17:58:23.181  INFO 20556 --- [           main] c.h.f.c.e.s.r.ClickHouseApplication      : Started ClickHouseApplication in 1.388 seconds (JVM running for 3.989)
    2023-02-06 17:58:32.640  INFO 20556 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
    2023-02-06 17:58:32.640  INFO 20556 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
    2023-02-06 17:58:32.641  INFO 20556 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 1 ms
    2023-02-06 17:58:32.656  INFO 20556 --- [nio-8080-exec-1] .f.c.e.s.r.c.ClickHouseExampleController : Begin to execute query in clickhouse...
    2023-02-06 17:58:32.658  INFO 20556 --- [nio-8080-exec-1] c.h.f.c.e.s.r.impl.ClickHouseFunc        : loadBalancerIPList is 192.168.6.24, loadBalancerHttpPort is 21422, user is ckuser, clusterName is default_cluster, isSec is true.
    2023-02-06 17:58:32.659  INFO 20556 --- [nio-8080-exec-1] c.h.f.c.e.s.r.impl.ClickHouseFunc        : ckLbServerList current member is 0, ClickhouseBalancer is 192.168.6.24:21422
    2023-02-06 17:58:32.664  INFO 20556 --- [nio-8080-exec-1] ru.yandex.clickhouse.ClickHouseDriver    : Driver registered
    2023-02-06 17:58:32.665  INFO 20556 --- [nio-8080-exec-1] c.h.f.c.e.s.restclient.impl.Util         : Try times is 0, current load balancer is 192.168.6.24:21422.
    2023-02-06 17:58:35.494  INFO 20556 --- [nio-8080-exec-1] c.h.f.c.e.s.restclient.impl.Util         : Execute sql drop table if exists testdb.testtb on cluster default_cluster no delay, time is 216 ms
    2023-02-06 17:58:35.495  INFO 20556 --- [nio-8080-exec-1] c.h.f.c.e.s.restclient.impl.Util         : Try times is 0, current load balancer is 192.168.6.24:21422.
    2023-02-06 17:58:36.074  INFO 20556 --- [nio-8080-exec-1] c.h.f.c.e.s.restclient.impl.Util         : Execute sql drop table if exists testdb.testtb_all on cluster default_cluster no delay, time is 196 ms
    2023-02-06 17:58:36.074  INFO 20556 --- [nio-8080-exec-1] c.h.f.c.e.s.restclient.impl.Util         : Try times is 0, current load balancer is 192.168.6.24:21422.
    2023-02-06 17:58:36.765  INFO 20556 --- [nio-8080-exec-1] c.h.f.c.e.s.restclient.impl.Util         : Execute sql create database if not exists testdb on cluster default_cluster, time is 218 ms
    2023-02-06 17:58:36.765  INFO 20556 --- [nio-8080-exec-1] c.h.f.c.e.s.restclient.impl.Util         : Try times is 0, current load balancer is 192.168.6.24:21422.
    2023-02-06 17:58:37.364  INFO 20556 --- [nio-8080-exec-1] c.h.f.c.e.s.restclient.impl.Util         : Execute sql create table testdb.testtb on cluster default_cluster (name String, age UInt8, date Date)engine=ReplicatedMergeTree('/clickhouse/tables/{shard}/testdb.testtb','{replica}') partition by toYYYYMM(date) order by age, time is 198 ms
    2023-02-06 17:58:37.366  INFO 20556 --- [nio-8080-exec-1] c.h.f.c.e.s.restclient.impl.Util         : Try times is 0, current load balancer is 192.168.6.24:21422.
    2023-02-06 17:58:37.872  INFO 20556 --- [nio-8080-exec-1] c.h.f.c.e.s.restclient.impl.Util         : Execute sql create table testdb.testtb_all on cluster default_cluster as testdb.testtb ENGINE = Distributed(default_cluster,testdb,testtb, rand());, time is 160 ms
    2023-02-06 17:58:38.959  INFO 20556 --- [nio-8080-exec-1] c.h.f.c.e.s.restclient.impl.Util         : Insert batch time is 591 ms
    2023-02-06 17:58:41.114  INFO 20556 --- [nio-8080-exec-1] c.h.f.c.e.s.restclient.impl.Util         : Insert batch time is 572 ms
    2023-02-06 17:58:43.095  INFO 20556 --- [nio-8080-exec-1] c.h.f.c.e.s.restclient.impl.Util         : Insert batch time is 413 ms
    2023-02-06 17:58:45.220  INFO 20556 --- [nio-8080-exec-1] c.h.f.c.e.s.restclient.impl.Util         : Insert batch time is 543 ms
    2023-02-06 17:58:47.207  INFO 20556 --- [nio-8080-exec-1] c.h.f.c.e.s.restclient.impl.Util         : Insert batch time is 406 ms
    2023-02-06 17:58:49.236  INFO 20556 --- [nio-8080-exec-1] c.h.f.c.e.s.restclient.impl.Util         : Insert batch time is 460 ms
    2023-02-06 17:58:51.197  INFO 20556 --- [nio-8080-exec-1] c.h.f.c.e.s.restclient.impl.Util         : Insert batch time is 390 ms
    2023-02-06 17:58:53.233  INFO 20556 --- [nio-8080-exec-1] c.h.f.c.e.s.restclient.impl.Util         : Insert batch time is 466 ms
    2023-02-06 17:58:55.355  INFO 20556 --- [nio-8080-exec-1] c.h.f.c.e.s.restclient.impl.Util         : Insert batch time is 555 ms
    2023-02-06 17:58:57.321  INFO 20556 --- [nio-8080-exec-1] c.h.f.c.e.s.restclient.impl.Util         : Insert batch time is 386 ms
    2023-02-06 17:58:58.832  INFO 20556 --- [nio-8080-exec-1] c.h.f.c.e.s.restclient.impl.Util         : Inert all batch time is 20564 ms
    2023-02-06 17:58:58.832  INFO 20556 --- [nio-8080-exec-1] c.h.f.c.e.s.restclient.impl.Util         : Try times is 0, current load balancer is 192.168.6.24:21422.
    2023-02-06 17:58:59.256  INFO 20556 --- [nio-8080-exec-1] c.h.f.c.e.s.restclient.impl.Util         : Execute sql select * from testdb.testtb_all order by age limit 10, time is 119 ms
    2023-02-06 17:58:59.257  INFO 20556 --- [nio-8080-exec-1] c.h.f.c.e.s.restclient.impl.Util         : Try times is 0, current load balancer is 192.168.6.24:21422.
    2023-02-06 17:58:59.972  INFO 20556 --- [nio-8080-exec-1] c.h.f.c.e.s.restclient.impl.Util         : Execute sql select toYYYYMM(date),count(1) from testdb.testtb_all group by toYYYYMM(date) order by count(1) DESC limit 10, time is 289 ms
    2023-02-06 17:58:59.973  INFO 20556 --- [nio-8080-exec-1] c.h.f.c.e.s.r.impl.ClickHouseFunc        : huawei_234	0	2022-12-16
    2023-02-06 17:58:59.973  INFO 20556 --- [nio-8080-exec-1] c.h.f.c.e.s.r.impl.ClickHouseFunc        : huawei_1805	0	2022-12-21
    2023-02-06 17:58:59.973  INFO 20556 --- [nio-8080-exec-1] c.h.f.c.e.s.r.impl.ClickHouseFunc        : huawei_3359	0	2022-12-13
    2023-02-06 17:58:59.973  INFO 20556 --- [nio-8080-exec-1] c.h.f.c.e.s.r.impl.ClickHouseFunc        : huawei_4275	0	2022-12-09
    2023-02-06 17:58:59.973  INFO 20556 --- [nio-8080-exec-1] c.h.f.c.e.s.r.impl.ClickHouseFunc        : huawei_4307	0	2022-12-20
    2023-02-06 17:58:59.973  INFO 20556 --- [nio-8080-exec-1] c.h.f.c.e.s.r.impl.ClickHouseFunc        : huawei_4586	0	2022-12-02
    2023-02-06 17:58:59.973  INFO 20556 --- [nio-8080-exec-1] c.h.f.c.e.s.r.impl.ClickHouseFunc        : huawei_6326	0	2022-12-18
    2023-02-06 17:58:59.973  INFO 20556 --- [nio-8080-exec-1] c.h.f.c.e.s.r.impl.ClickHouseFunc        : huawei_9878	0	2022-12-06
    2023-02-06 17:58:59.974  INFO 20556 --- [nio-8080-exec-1] c.h.f.c.e.s.r.impl.ClickHouseFunc        : huawei_2482	0	2022-12-18
    2023-02-06 17:58:59.974  INFO 20556 --- [nio-8080-exec-1] c.h.f.c.e.s.r.impl.ClickHouseFunc        : huawei_2904	0	2022-12-25
    2023-02-06 17:58:59.974  INFO 20556 --- [nio-8080-exec-1] c.h.f.c.e.s.r.impl.ClickHouseFunc        : 202201	8628
    2023-02-06 17:58:59.974  INFO 20556 --- [nio-8080-exec-1] c.h.f.c.e.s.r.impl.ClickHouseFunc        : 202208	8587
    2023-02-06 17:58:59.974  INFO 20556 --- [nio-8080-exec-1] c.h.f.c.e.s.r.impl.ClickHouseFunc        : 202205	8558
    2023-02-06 17:58:59.974  INFO 20556 --- [nio-8080-exec-1] c.h.f.c.e.s.r.impl.ClickHouseFunc        : 202210	8547
    2023-02-06 17:58:59.974  INFO 20556 --- [nio-8080-exec-1] c.h.f.c.e.s.r.impl.ClickHouseFunc        : 202207	8463
    2023-02-06 17:58:59.974  INFO 20556 --- [nio-8080-exec-1] c.h.f.c.e.s.r.impl.ClickHouseFunc        : 202203	8379
    2023-02-06 17:58:59.974  INFO 20556 --- [nio-8080-exec-1] c.h.f.c.e.s.r.impl.ClickHouseFunc        : 202204	8351
    2023-02-06 17:58:59.974  INFO 20556 --- [nio-8080-exec-1] c.h.f.c.e.s.r.impl.ClickHouseFunc        : 202206	8300
    2023-02-06 17:58:59.974  INFO 20556 --- [nio-8080-exec-1] c.h.f.c.e.s.r.impl.ClickHouseFunc        : 202209	8297
    2023-02-06 17:58:59.974  INFO 20556 --- [nio-8080-exec-1] c.h.f.c.e.s.r.impl.ClickHouseFunc        : 202212	8228

分享:

    相关文档

    相关产品