jacoco功能測試-代碼覆蓋率

1、下載 jacoco

官網地址:EclEmma - JaCoCo Java Code Coverage Library

2、拷貝 jar 包?

下載好后,找到這兩個文件,然后找到被測項目

3、啟動 jacocoagent,監控被測項目?

java -javaagent:jacocoagent.jar=includes=*,output=tcpserver,port=6300,address=localhost,append=true -jar jacoco-demo-1.0.0.jar 
#jacoco-demo-1.0.0.jar為被測項目jar包
$ java -javaagent:jacocoagent.jar=includes=*,output=tcpserver,port=6300,address=localhost,append=true -jar jacoco-demo-1.0.0.jar
16:23:53,451 |-INFO in ch.qos.logback.classic.LoggerContext[default] - This is logback-classic version 1.4.5
16:23:53,467 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback-test.xml]
16:23:53,483 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback.xml] at [jar:file:/E:/soft/jacoco/jacoco-0.8.10/lib/jacoco-demo-1.0.0.jar!/BOOT-INF/classes!/logback.xml]
16:23:53,499 |-INFO in ch.qos.logback.core.joran.spi.ConfigurationWatchList@4808bc9b - URL [jar:file:/E:/soft/jacoco/jacoco-0.8.10/lib/jacoco-demo-1.0.0.jar!/BOOT-INF/classes!/logback.xml] is not of type file
16:23:53,658 |-INFO in ch.qos.logback.core.model.processor.AppenderModelHandler - Processing appender named [stdout]
16:23:53,658 |-INFO in ch.qos.logback.core.model.processor.AppenderModelHandler - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]
16:23:53,674 |-INFO in ch.qos.logback.core.model.processor.ImplicitModelHandler - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
16:23:53,722 |-INFO in ch.qos.logback.core.model.processor.AppenderModelHandler - Processing appender named [ErrorFile]
16:23:53,722 |-INFO in ch.qos.logback.core.model.processor.AppenderModelHandler - About to instantiate appender of type [ch.qos.logback.core.rolling.RollingFileAppender]
16:23:53,738 |-INFO in c.q.l.core.rolling.TimeBasedRollingPolicy@1893960929 - No compression will be used
16:23:53,738 |-INFO in c.q.l.core.rolling.TimeBasedRollingPolicy@1893960929 - Will use the pattern c:/logs/error/error-%d{yyyy-MM-dd}.%i.log for the active file
16:23:53,770 |-INFO in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@2ca923bb - The date pattern is 'yyyy-MM-dd' from file name pattern 'c:/logs/error/error-%d{yyyy-MM-dd}.%i.log'.
16:23:53,770 |-INFO in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@2ca923bb - Roll-over at midnight.
16:23:53,786 |-INFO in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@2ca923bb - Setting initial period to Sun Aug 13 16:11:32 CST 2023
16:23:53,786 |-WARN in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@2ca923bb - SizeAndTimeBasedFNATP is deprecated. Use SizeAndTimeBasedRollingPolicy instead
16:23:53,786 |-WARN in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@2ca923bb - For more information see http://logback.qos.ch/manual/appenders.html#SizeAndTimeBasedRollingPolicy
16:23:53,794 |-WARN in ch.qos.logback.core.rolling.RollingFileAppender[ErrorFile] - This appender no longer admits a layout as a sub-component, set an encoder instead.
16:23:53,794 |-WARN in ch.qos.logback.core.rolling.RollingFileAppender[ErrorFile] - To ensure compatibility, wrapping your layout in LayoutWrappingEncoder.
16:23:53,794 |-WARN in ch.qos.logback.core.rolling.RollingFileAppender[ErrorFile] - See also http://logback.qos.ch/codes.html#layoutInsteadOfEncoder for details
16:23:53,794 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[ErrorFile] - Active log file name: c:/logs/error/error.log
16:23:53,794 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[ErrorFile] - File property is set to [c:/logs/error/error.log]
16:23:53,802 |-INFO in ch.qos.logback.core.model.processor.AppenderModelHandler - Processing appender named [AllFile]
16:23:53,802 |-INFO in ch.qos.logback.core.model.processor.AppenderModelHandler - About to instantiate appender of type [ch.qos.logback.core.rolling.RollingFileAppender]
16:23:53,802 |-INFO in c.q.l.core.rolling.TimeBasedRollingPolicy@333392524 - No compression will be used
16:23:53,802 |-INFO in c.q.l.core.rolling.TimeBasedRollingPolicy@333392524 - Will use the pattern c:/logs/all/all-%d{yyyy-MM-dd}.%i.log for the active file
16:23:53,802 |-INFO in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@1ebea008 - The date pattern is 'yyyy-MM-dd' from file name pattern 'c:/logs/all/all-%d{yyyy-MM-dd}.%i.log'.
16:23:53,802 |-INFO in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@1ebea008 - Roll-over at midnight.
16:23:53,802 |-INFO in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@1ebea008 - Setting initial period to Sun Aug 13 16:22:01 CST 2023
16:23:53,802 |-WARN in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@1ebea008 - SizeAndTimeBasedFNATP is deprecated. Use SizeAndTimeBasedRollingPolicy instead
16:23:53,802 |-WARN in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@1ebea008 - For more information see http://logback.qos.ch/manual/appenders.html#SizeAndTimeBasedRollingPolicy
16:23:53,802 |-WARN in ch.qos.logback.core.rolling.RollingFileAppender[AllFile] - This appender no longer admits a layout as a sub-component, set an encoder instead.
16:23:53,802 |-WARN in ch.qos.logback.core.rolling.RollingFileAppender[AllFile] - To ensure compatibility, wrapping your layout in LayoutWrappingEncoder.
16:23:53,802 |-WARN in ch.qos.logback.core.rolling.RollingFileAppender[AllFile] - See also http://logback.qos.ch/codes.html#layoutInsteadOfEncoder for details
16:23:53,802 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[AllFile] - Active log file name: c:/logs/all/all.log
16:23:53,802 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[AllFile] - File property is set to [c:/logs/all/all.log]
16:23:53,802 |-INFO in ch.qos.logback.classic.model.processor.RootLoggerModelHandler - Setting level of ROOT logger to INFO
16:23:53,802 |-INFO in ch.qos.logback.core.model.processor.AppenderRefModelHandler - Attaching appender named [stdout] to Logger[ROOT]
16:23:53,802 |-INFO in ch.qos.logback.core.model.processor.AppenderRefModelHandler - Attaching appender named [ErrorFile] to Logger[ROOT]
16:23:53,802 |-INFO in ch.qos.logback.core.model.processor.AppenderRefModelHandler - Attaching appender named [AllFile] to Logger[ROOT]
16:23:53,802 |-INFO in ch.qos.logback.core.model.processor.DefaultProcessor@72d6b3ba - End of configuration.
16:23:53,802 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator@1787f2a0 - Registering current configuration as safe fallback point16:23:54,405 |-INFO in ch.qos.logback.core.joran.spi.ConfigurationWatchList@64030b91 - URL [jar:file:/E:/soft/jacoco/jacoco-0.8.10/lib/jacoco-demo-1.0.0.jar!/BOOT-INF/classes!/logback.xml] is not of type file
16:23:54,422 |-INFO in ch.qos.logback.core.model.processor.AppenderModelHandler - Processing appender named [stdout]
16:23:54,422 |-INFO in ch.qos.logback.core.model.processor.AppenderModelHandler - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]
16:23:54,422 |-INFO in ch.qos.logback.core.model.processor.ImplicitModelHandler - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
16:23:54,422 |-INFO in ch.qos.logback.core.model.processor.AppenderModelHandler - Processing appender named [ErrorFile]
16:23:54,422 |-INFO in ch.qos.logback.core.model.processor.AppenderModelHandler - About to instantiate appender of type [ch.qos.logback.core.rolling.RollingFileAppender]
16:23:54,422 |-INFO in c.q.l.core.rolling.TimeBasedRollingPolicy@540206885 - No compression will be used
16:23:54,422 |-INFO in c.q.l.core.rolling.TimeBasedRollingPolicy@540206885 - Will use the pattern c:/logs/error/error-%d{yyyy-MM-dd}.%i.log for the active file
16:23:54,422 |-INFO in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@4d23015c - The date pattern is 'yyyy-MM-dd' from file name pattern 'c:/logs/error/error-%d{yyyy-MM-dd}.%i.log'.
16:23:54,422 |-INFO in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@4d23015c - Roll-over at midnight.
16:23:54,422 |-INFO in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@4d23015c - Setting initial period to Sun Aug 13 16:11:32 CST 2023
16:23:54,422 |-WARN in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@4d23015c - SizeAndTimeBasedFNATP is deprecated. Use SizeAndTimeBasedRollingPolicy instead
16:23:54,422 |-WARN in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@4d23015c - For more information see http://logback.qos.ch/manual/appenders.html#SizeAndTimeBasedRollingPolicy
16:23:54,422 |-WARN in ch.qos.logback.core.rolling.RollingFileAppender[ErrorFile] - This appender no longer admits a layout as a sub-component, set an encoder instead.
16:23:54,422 |-WARN in ch.qos.logback.core.rolling.RollingFileAppender[ErrorFile] - To ensure compatibility, wrapping your layout in LayoutWrappingEncoder.
16:23:54,422 |-WARN in ch.qos.logback.core.rolling.RollingFileAppender[ErrorFile] - See also http://logback.qos.ch/codes.html#layoutInsteadOfEncoder for details
16:23:54,422 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[ErrorFile] - Active log file name: c:/logs/error/error.log
16:23:54,422 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[ErrorFile] - File property is set to [c:/logs/error/error.log]
16:23:54,422 |-INFO in ch.qos.logback.core.model.processor.AppenderModelHandler - Processing appender named [AllFile]
16:23:54,422 |-INFO in ch.qos.logback.core.model.processor.AppenderModelHandler - About to instantiate appender of type [ch.qos.logback.core.rolling.RollingFileAppender]
16:23:54,422 |-INFO in c.q.l.core.rolling.TimeBasedRollingPolicy@943659381 - No compression will be used
16:23:54,422 |-INFO in c.q.l.core.rolling.TimeBasedRollingPolicy@943659381 - Will use the pattern c:/logs/all/all-%d{yyyy-MM-dd}.%i.log for the active file
16:23:54,422 |-INFO in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@441cc260 - The date pattern is 'yyyy-MM-dd' from file name pattern 'c:/logs/all/all-%d{yyyy-MM-dd}.%i.log'.
16:23:54,422 |-INFO in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@441cc260 - Roll-over at midnight.
16:23:54,422 |-INFO in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@441cc260 - Setting initial period to Sun Aug 13 16:22:01 CST 2023
16:23:54,422 |-WARN in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@441cc260 - SizeAndTimeBasedFNATP is deprecated. Use SizeAndTimeBasedRollingPolicy instead
16:23:54,422 |-WARN in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@441cc260 - For more information see http://logback.qos.ch/manual/appenders.html#SizeAndTimeBasedRollingPolicy
16:23:54,422 |-WARN in ch.qos.logback.core.rolling.RollingFileAppender[AllFile] - This appender no longer admits a layout as a sub-component, set an encoder instead.
16:23:54,422 |-WARN in ch.qos.logback.core.rolling.RollingFileAppender[AllFile] - To ensure compatibility, wrapping your layout in LayoutWrappingEncoder.
16:23:54,422 |-WARN in ch.qos.logback.core.rolling.RollingFileAppender[AllFile] - See also http://logback.qos.ch/codes.html#layoutInsteadOfEncoder for details
16:23:54,422 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[AllFile] - Active log file name: c:/logs/all/all.log
16:23:54,422 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[AllFile] - File property is set to [c:/logs/all/all.log]
16:23:54,422 |-INFO in ch.qos.logback.classic.model.processor.RootLoggerModelHandler - Setting level of ROOT logger to INFO
16:23:54,422 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@73a00e09 - Propagating INFO level on Logger[ROOT] onto the JUL framework
16:23:54,422 |-INFO in ch.qos.logback.core.model.processor.AppenderRefModelHandler - Attaching appender named [stdout] to Logger[ROOT]
16:23:54,422 |-INFO in ch.qos.logback.core.model.processor.AppenderRefModelHandler - Attaching appender named [ErrorFile] to Logger[ROOT]
16:23:54,422 |-INFO in ch.qos.logback.core.model.processor.AppenderRefModelHandler - Attaching appender named [AllFile] to Logger[ROOT]
16:23:54,422 |-INFO in ch.qos.logback.core.model.processor.DefaultProcessor@26dcd8c0 - End of configuration.
16:23:54,422 |-INFO in org.springframework.boot.logging.logback.SpringBootJoranConfigurator@66e889df - Registering current configuration as safe fallback point.   ____          _            __ _ _/\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \\\/  ___)| |_)| | | | | || (_| |  ) ) ) )'  |____| .__|_| |_|_| |_\__, | / / / /=========|_|==============|___/=/_/_/_/:: Spring Boot ::                (v3.0.2)[INFO ] 2023-08-13 16:23:54.557 [main] com.ybw.JacocoDemoApplication - Starting JacocoDemoApplication using Java 17.0.4.1 with PID 11912 (E:\soft\jacoco\jacoco-0.8.10\lib\jacoco-demo-1.0.0.jar started by 魏先生 in E:\soft\jacoco\jacoco-0.8.10\lib)
[INFO ] 2023-08-13 16:23:54.557 [main] com.ybw.JacocoDemoApplication - No active profile set, falling back to 1 default profile: "default"
[INFO ] 2023-08-13 16:23:55.593 [main] o.s.b.w.e.tomcat.TomcatWebServer - Tomcat initialized with port(s): 8080 (http)
[INFO ] 2023-08-13 16:23:55.597 [main] o.a.coyote.http11.Http11NioProtocol - Initializing ProtocolHandler ["http-nio-8080"]
[INFO ] 2023-08-13 16:23:55.597 [main] o.a.catalina.core.StandardService - Starting service [Tomcat]
[INFO ] 2023-08-13 16:23:55.597 [main] o.a.catalina.core.StandardEngine - Starting Servlet engine: [Apache Tomcat/10.1.5]
[INFO ] 2023-08-13 16:23:55.673 [main] o.a.c.c.C.[Tomcat].[localhost].[/] - Initializing Spring embedded WebApplicationContext
[INFO ] 2023-08-13 16:23:55.688 [main] o.s.b.w.s.c.ServletWebServerApplicationContext - Root WebApplicationContext: initialization completed in 1042 ms
[INFO ] 2023-08-13 16:23:56.038 [main] o.a.coyote.http11.Http11NioProtocol - Starting ProtocolHandler ["http-nio-8080"]
[INFO ] 2023-08-13 16:23:56.054 [main] o.s.b.w.e.tomcat.TomcatWebServer - Tomcat started on port(s): 8080 (http) with context path ''
[INFO ] 2023-08-13 16:23:56.054 [main] com.ybw.JacocoDemoApplication - Started JacocoDemoApplication in 2.115 seconds (process running for 2.942)

參數描述

  • includes=*:這個代表了,啟動時需要進行字節碼插樁的包過濾,*代表所有的class文件加載都需要進行插樁。
    • 你可以寫成: includes=com.test.service.*;這個參數我們可以用來做maven多模塊的覆蓋率,比如我們只想查看service服務層的覆蓋率,我們可以通過設置包路徑的方式進行只統計當前包的覆蓋率。
  • output=tcpserver:output主要四個參數
    • file: At VM termination execution data is written to the file specified in the destfile attribute.(當jvm停止掉的時候產出dump文件,即服務掛了產出dump文件)

    • tcpserver: The agent listens for incoming connections on the TCP port specified by the?address and port attribute. Execution data is written to this TCP connection.(常用模式,將jacocoaget作為服務,每次通過cli包進行dump命令去獲取dump包)

    • tcpclient: At startup the agent connects to the TCP port specified by the address and port attribute. Execution data is written to this TCP connection.(將jacocoagent做為客戶端,向指定ip和端口的服務推送dump信息)

    • none: Do not produce any output.(不產出任何dump,dump個寂寞,忽略)

  • port=6300:這是jacoco開啟的tcpserver的端口,請注意這個端口不能被占用。

  • address=localhost:這是對外開發的tcpserver的訪問地址。

    • 可以配置127.0.0.1,也可以配置為實際訪問ip配置為127.0.0.1的時候,dump數據只能在這臺服務器上進行dump,就不能通過遠程方式dump數據。配置為實際的ip地址的時候,就可以在任意一臺機器上(前提是ip要通,不通都白瞎),通過ant xml或者api方式dump數據。

    • 舉個栗子:我如上配置了192.168.110.1:2014作為jacoco的tcpserver啟動服務,
      那我可以在任意一臺機器上進行數據的dump,比如在我本機windows上用api或者xml方式調用dump。如果我配置了127.0.0.1:2014作為啟動服務器,那么我只能在這臺測試機上進行dump,其他的機器都無法連接到這個tcpserver進行dump

    • 如果不知道本機ip地址,可以使用0.0.0.0,這樣ip地址會綁定主機ip。

  • append=true:是執行數據文件已經存在,則覆蓋數據將附加到現有文件。

頁面或接口調用

調用接口http://localhost:8080/user/getUser?id=1

4、cli 包 dump 生成 exec 文件(注意一定要測試完畢之后)

$ java -jar jacococli.jar dump --address localhost --port 6300 --destfile jacoco-demo.exec
[INFO] Connecting to localhost/127.0.0.1:6300.
[INFO] Writing execution data to E:\gitcode\mygit\learn\jacoco\jacoco-demo\target\jacoco-demo.exec.
  • --address localhost?--port 6300 指向jacocoagent啟動IP和端口

  • jacoco-demo.exec 為生成exec文件名

5、生成report?

$ java -jar jacococli.jar report jacoco-demo.exec --classfiles E:/gitcode/mygit/learn/jacoco/jacoco-demo/target/classes --sourcefiles E:/gitcode/mygit/learn/jacoco/jacoco-demo/src/main/java --html html-report --xml report.xml --encoding=utf-8
[INFO] Loading execution data file E:\gitcode\mygit\learn\jacoco\jacoco-demo\target\jacoco-demo.exec.
[INFO] Analyzing 4 classes.
  • --sourcefiles 和 --classfiles 為本地被測項目源碼和字節碼路徑。
  • --html 為生成報告目錄。

6、查看覆蓋率報告

?

表格

  • Element:元素;
  • Missed Instructions?? ?Cov:未覆蓋字節碼行數;
  • Missed Branches?? ?Cov:未覆蓋的分支數;
  • Cxty:圈復雜度;
  • Lines:行;
  • Methods:方法;
  • Classes:類;?

覆蓋率標識

  • 條件覆蓋:紅鉆:表示未覆蓋;黃鉆:表示部分覆蓋;綠鉆:表示全部覆蓋;
  • 行覆蓋:全覆蓋(綠色),未覆蓋(紅色),半覆蓋(黃色),無視(白色)

只調用http://localhost:8080/user/getUser?id=1,效果如下

調用如下接口

http://localhost:8080/user/getUser?id=1、http://localhost:8080/user/getUser?id=2、http://localhost:8080/user/getUser?id=3???????、http://localhost:8080/user/getUser?id=5

效果如下,覆蓋率為100%:

?

?

?

7、單元測試

上面都是功能測試代碼覆蓋率,jacoco單元測試文章可以看:

idea 測試覆蓋率_idea單元測試覆蓋率_xixingzhe2的博客-CSDN博客

8、demo代碼

share: 分享倉庫 - Gitee.com

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/35213.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/35213.shtml
英文地址,請注明出處:http://en.pswp.cn/news/35213.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

【Java】異常處理 之 使用Log4j

使用 Log4j 前面介紹了Commons Logging,可以作為“日志接口”來使用。而真正的“日志實現”可以使用Log4j。 Log4j是一種非常流行的日志框架,最新版本是2.x。 Log4j是一個組件化設計的日志系統,它的架構大致如下: log.info(&q…

linux0.95(VFS重點)源碼通俗解讀(施工中)

文件系統在磁盤中的體現 下面是磁盤的內容,其中i節點就是一個inode數組,邏輯塊就是數據塊可用于存放數據 操作系統通過將磁盤數據讀入到內存中指定的緩沖區塊來與磁盤交互,對內存中的緩沖區塊修改后寫回磁盤。 進程(task_struct * task[N…

Mysql中如果建立了索引,索引所占的空間隨著數據量增長而變大,這樣無論寫入還是查詢,性能都會有所下降,怎么處理?

索引所占空間的增長確實會對MySQL數據庫的寫入性能和查詢性能造成影響,這主要是由于索引數據過多時會導致磁盤I/O操作變得非常頻繁,從而使性能下降。為此,可以采取以下幾種方式來減緩這種影響: 1. 限制索引的大小:可以…

Netty框架技術文檔-基本概念

Netty: Home https://github.com/netty/netty 基本概念 NIO(Non-blocking I/O,非阻塞I/O):NIO是一種Java平臺的I/O模型,它使用Channel和Buffer來進行數據傳輸,而不是傳統的Stream。NIO模型可以處理大量并…

TCP除了3次握手,其他的這些你知道嗎?

文章首發地址 MSS: MSS(Maximum Segment Size)表示TCP報文段的最大長度,通常是MSSMTU-TCP頭部長度。由于數據鏈路層協議的MTU可能不同,因此TCP連接建立時會通過MSS選項告知對方報文段的最大長度。MTU: MTU…

【探索SpringCloud】服務發現-Nacos使用

前言 在聊服務注冊中心時,便提到了Nacos。這次便來認識一下。當然,這自然沒有官方介紹那般詳盡,權當是學習了解Nacos原理的一個過程吧。 Nacos簡介 Nacos,全名:dynamic Naming And Configuration Service. 而這個名…

Java JDBC,輕松構建數據庫連接:代碼教程詳解

JDBC的概述 Java Database Connectivity(JDBC)是 Java 中用于與數據庫進行通信的 API。它提供了一套標準的 API,并允許 Java 應用程序連接到各種關系型數據庫,如 MySQL、Oracle、PostgreSQL 等,從而可以執行 SQL 查詢…

win10在vmware15中安裝macos10.13系統

第一步、安裝vmware版本信息如下 第二步、下載unlocker-main和darwin.iso放到安裝文件夾 第三步、管理員身份運行win-install.cmd 第四步、運行vmware新建虛擬機 第五步、啟動新創建的虛擬機macOS 10.13并選擇語言 第六步、選擇磁盤工具抹掉磁盤 第七步、格式化完成后退出磁盤工…

flutter 隨筆

萬物 皆可 結構 概念 ?狀態 插件類 flutter系統類 MaterialApp源App應? 事件 很簡單/簡單/較復雜/復雜/很復雜 結構體 MaterialApp(xx:) 公開坑位屬性:所配置內容 Widget 插件事件 function 函數事件 flutter/dart 事件結構描述void Function() 外層主事件 內層回…

數據結構:交換排序

冒泡排序 起泡排序,別名“冒泡排序”,該算法的核心思想是將無序表中的所有記錄,通過兩兩比較關鍵字,得出升序序列或者降序序列。 算法步驟 比較相鄰的元素。如果第一個元素大于第二個元素,就交換它們。對每一對相鄰…

Python-OpenCV中的圖像處理-圖像金字塔

Python-OpenCV中的圖像處理-圖像金字塔 圖像金字塔高斯金字塔拉普拉斯金字塔 金字塔圖像融合 圖像金字塔 同一圖像的不同分辨率的子圖集合,如果把最大的圖像放在底部,最小的放在頂部,看起來像一座金字塔,故而得名圖像金字塔。cv2…

小程序發布注意事項

1、使用HBuildx的 發布 功能發布小程序,因為編譯完的代碼目錄不是同一個 如果使用 運行 到小程序,最后發布的版本會顯示”無法連接本地服務器“ 2、使用unicloud的云服務 uniCloud發行 | uni-app官網 阿里云的unicloud的話,使用request域名…

Spring中Bean的循環依賴問題

1.什么是Bean的循環依賴? 簡單來說就是在A類中,初始化A時需要用到B對象,而在B類中,初始化B時需要用到A對象,這種狀況下在Spring中,如果A和B同時初始化,A,B同時都需要對方的資源&…

電腦開機出現Boot Device怎么辦?

開機出現Boot Device這個問題很常見,有時還會出現No Boot Device的問題,雖然多了一個單詞,但意思是相同的,這些問題說明你的系統盤出現了問題,或者是引導出現了問題。這該如何解決呢? 方法1. 檢查主板或硬盤…

【算法——雙指針】LeetCode 283 移動零

題目描述: 思路: (雙指針) O(n)O(n)O(n) 給定一個數組 nums,要求我們將所有的 0 移動到數組的末尾,同時保持非零元素的相對順序。 如圖所示,數組nums [0,1,0,3,12],移動完成后變成nums [1,3,12,0,0] &am…

若依vue -【 100 ~ 更 ~ 110 】

100 主子表代碼生成詳解 1 新建數據庫表結構(主子表) -- ---------------------------- -- 客戶表 -- ---------------------------- drop table if exists sys_customer; create table sys_customer (customer_id bigint(20) not null…

Docker部署rabbitmq遇到的問題 Stats in management UI are disabled on this node

1. Stats in management UI are disabled on this node #進入rabbitmq容器 docker exec -it {rabbitmq容器名稱或者id} /bin/bash#進入容器后,cd到以下路徑 cd /etc/rabbitmq/conf.d/#修改 management_agent.disable_metrics_collector false echo management_age…

談談語音助手

目錄 1.什么是語音助手 2.語音助手的發展過程 3.現在有哪些成熟的語音助手 4.語音助手對人類發展的影響 1.什么是語音助手 語音助手是一種能夠通過語音交互與用戶進行溝通和執行任務的虛擬助手。它基于人工智能和自然語言處理技術,能夠理解用戶的語音指令&#x…

數據結構-隊列的實現(C語言版)

前言 隊列是一種特殊的線性表,它只允許在一端對數據進行插入操作,在另一端對數據進行刪除操作的特殊線性表,隊列具有先進先出的(FIFO)的 特性,進行插入操作的一端稱為隊尾,進行刪除操作的一端稱…

JZ37序列化二叉樹

題目地址:序列化二叉樹_牛客題霸_牛客網 題目回顧: 解題思路: 首先,序列化就是將二叉樹的節點值放入一個字符串中,這里可以按照前序遍歷的思路來進行操作,謙虛遍歷是:根左右的情況,…