Maven - 統一構建規范:Maven 插件管理最佳實踐

文章目錄

  • Available Plugins
  • 開源項目中的使用
  • 插件介紹
    • maven-jar-plugin
    • maven-assembly-plugin
    • maven-shade-plugin
      • Shade 插件 - 標簽
        • artifactSet
        • relocations
        • filters
      • 完整配置

在這里插入圖片描述


Available Plugins

https://maven.apache.org/plugins/index.html

Maven 是一個開源的軟件構建工具,它支持多種插件,用于幫助開發人員更方便地管理構建過程中所需的各種資源。以下是一些常用的 Maven 插件:

  1. Maven-clean-plugin:用于清除項目目錄中的垃圾文件和臨時文件。
  2. Maven-compile-plugin:用于編譯項目源代碼,生成目標代碼。
  3. Maven-dependency-plugin:用于管理項目依賴關系,可以自動下載依賴庫,并解決依賴沖突。
  4. Maven-jar-plugin:用于打包項目,生成 JAR 文件。
  5. Maven-javadoc-plugin:用于生成項目 Javadoc 文檔。
  6. Maven-install-plugin:用于安裝項目依賴庫,可以將依賴庫安裝到本地倉庫中。
  7. Maven-deploy-plugin:用于部署項目,可以將項目打包成可執行的包,并上傳到遠程倉庫中。
  8. Maven-site-plugin:用于生成項目網站,可以自動生成 HTML 文檔,并上傳到遠程倉庫中。
  9. Maven-scm-plugin:用于管理項目版本,可以與版本控制系統集成,實現代碼的版本控制。
  10. Maven-release-plugin:用于發布項目,可以將項目打包成可執行的包,并上傳到遠程倉庫中,同時發布版本更新信息。
    在這里插入圖片描述

這些插件可以幫助開發人員更方便地管理構建過程中所需的各種資源,提高軟件構建的效率和質量。


開源項目中的使用

我們來看下nacos這個開源項目的plugin是如何使用的。 不得不說還是非常豐富的 。
在這里插入圖片描述

   <!-- =========================================================Build plugins================================================ --><!-- == --><build><plugins><plugin><groupId>org.codehaus.mojo</groupId><artifactId>versions-maven-plugin</artifactId><version>${versions-maven-plugin.version}</version></plugin><plugin><groupId>com.github.vongosling</groupId><artifactId>dependency-mediator-maven-plugin</artifactId><version>${dependency-mediator-maven-plugin.version}</version></plugin><plugin><groupId>org.codehaus.mojo</groupId><artifactId>clirr-maven-plugin</artifactId><version>${clirr-maven-plugin.version}</version></plugin><plugin><artifactId>maven-enforcer-plugin</artifactId><version>${maven-enforcer-plugin.version}</version><executions><execution><id>enforce-ban-circular-dependencies</id><goals><goal>enforce</goal></goals></execution></executions><configuration><rules><banCircularDependencies/></rules><fail>true</fail></configuration><dependencies><dependency><groupId>org.codehaus.mojo</groupId><artifactId>extra-enforcer-rules</artifactId><version>${extra-enforcer-rules.version}</version></dependency></dependencies></plugin><plugin><artifactId>maven-compiler-plugin</artifactId><version>${maven-compiler-plugin.version}</version><configuration><source>${maven.compiler.source}</source><target>${maven.compiler.target}</target><compilerVersion>${maven.compiler.source}</compilerVersion><showDeprecation>true</showDeprecation><showWarnings>true</showWarnings></configuration></plugin><plugin><artifactId>maven-javadoc-plugin</artifactId><version>${maven-javadoc-plugin.version}</version><configuration><charset>UTF-8</charset></configuration><executions><execution><id>attach-javadocs</id><goals><goal>jar</goal></goals></execution></executions></plugin><plugin><artifactId>maven-source-plugin</artifactId><version>${maven-source-plugin.version}</version><executions><execution><id>attach-sources</id><goals><goal>jar</goal></goals></execution></executions></plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-pmd-plugin</artifactId><version>${maven-pmd-plugin.version}</version><configuration><rulesets><ruleset>rulesets/java/ali-comment.xml</ruleset><ruleset>rulesets/java/ali-concurrent.xml</ruleset><ruleset>rulesets/java/ali-constant.xml</ruleset><ruleset>rulesets/java/ali-exception.xml</ruleset><ruleset>rulesets/java/ali-flowcontrol.xml</ruleset><ruleset>rulesets/java/ali-naming.xml</ruleset><ruleset>rulesets/java/ali-oop.xml</ruleset><ruleset>rulesets/java/ali-orm.xml</ruleset><ruleset>rulesets/java/ali-other.xml</ruleset><ruleset>rulesets/java/ali-set.xml</ruleset></rulesets><printFailingErrors>true</printFailingErrors><excludes><exclude>**/consistency/entity/*.java</exclude><exclude>**/istio/model/mcp/*.java</exclude><exclude>**/istio/model/naming/*.java</exclude><exclude>**/istio/model/*.java</exclude><exclude>**/api/grpc/auto/*.java</exclude><exclude>**/istio/mcp/**</exclude><exclude>**/istio/networking/**</exclude><exclude>**/google/protobuf/**</exclude></excludes></configuration><executions><execution><goals><goal>check</goal></goals></execution></executions><dependencies><dependency><groupId>com.alibaba.p3c</groupId><artifactId>p3c-pmd</artifactId><version>${p3c-pmd.version}</version></dependency></dependencies></plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-checkstyle-plugin</artifactId><version>${maven-checkstyle-plugin.version}</version><configuration><configLocation>style/NacosCheckStyle.xml</configLocation><includeTestSourceDirectory>true</includeTestSourceDirectory><encoding>UTF-8</encoding><consoleOutput>true</consoleOutput><failsOnError>true</failsOnError><excludes>**/consistency/entity/**,**/nacos/test/**,**/api/grpc/auto/**,**/istio/**,**/protobuf/**</excludes></configuration><executions><execution><id>validate</id><phase>validate</phase><goals><goal>check</goal></goals></execution></executions></plugin><plugin><groupId>org.apache.rat</groupId><artifactId>apache-rat-plugin</artifactId><version>${apache-rat-plugin.version}</version><configuration><excludes><exclude>.editorconfig</exclude><exclude>.travis.yml</exclude><exclude>CONTRIBUTING.md</exclude><exclude>CODE_OF_CONDUCT.md</exclude><exclude>CHANGELOG.md</exclude><exclude>style/codeStyle.md</exclude><exclude>REPORTING-BUGS.md</exclude><exclude>README.md</exclude><exclude>.github/**/*</exclude><exclude>doc/*</exclude><exclude>derby.log</exclude><exclude>logs/*</exclude><exclude>src/main/resources/static/**</exclude><exclude>**/istio/model/**</exclude><exclude>**/consistency/entity/**</exclude><exclude>**/*.txt</exclude><exclude>**/*.factories</exclude><exclude>/console-ui/**</exclude><exclude>**/gogo.proto</exclude><exclude>**/any.proto</exclude></excludes></configuration><executions><execution><phase>verify</phase><goals><goal>check</goal></goals></execution></executions></plugin><plugin><artifactId>maven-resources-plugin</artifactId><version>${maven-resources-plugin.version}</version><configuration><!-- We are not suppose to setup the customer resources here --><encoding>${project.build.sourceEncoding}</encoding></configuration></plugin><plugin><groupId>org.eluder.coveralls</groupId><artifactId>coveralls-maven-plugin</artifactId><version>${coveralls-maven-plugin.version}</version></plugin><plugin><groupId>org.jacoco</groupId><artifactId>jacoco-maven-plugin</artifactId><version>${jacoco-maven-plugin.version}</version><executions><execution><id>default-prepare-agent</id><goals><goal>prepare-agent</goal></goals><configuration><destFile>${project.build.directory}/jacoco.exec</destFile></configuration></execution><execution><id>default-prepare-agent-integration</id><phase>pre-integration-test</phase><goals><goal>prepare-agent-integration</goal></goals><configuration><destFile>${project.build.directory}/jacoco-it.exec</destFile><propertyName>failsafeArgLine</propertyName></configuration></execution><execution><id>default-report</id><goals><goal>report</goal></goals></execution><execution><id>default-report-integration</id><goals><goal>report-integration</goal></goals></execution></executions></plugin><plugin><artifactId>maven-surefire-plugin</artifactId><version>${maven-surefire-plugin.version}</version></plugin><plugin><groupId>org.codehaus.mojo</groupId><artifactId>findbugs-maven-plugin</artifactId><version>${findbugs-maven-plugin.version}</version></plugin><plugin><groupId>org.sonarsource.scanner.maven</groupId><artifactId>sonar-maven-plugin</artifactId><version>${sonar-maven-plugin.version}</version></plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-assembly-plugin</artifactId><version>${maven-assembly-plugin.version}</version></plugin><plugin><groupId>org.codehaus.mojo</groupId><artifactId>flatten-maven-plugin</artifactId><version>${maven-flatten-version}</version><configuration><updatePomFile>true</updatePomFile><flattenMode>resolveCiFriendliesOnly</flattenMode><pomElements><dependencies>expand</dependencies></pomElements></configuration><executions><execution><id>flatten</id><phase>process-resources</phase><goals><goal>flatten</goal></goals></execution><execution><id>flatten.clean</id><phase>clean</phase><goals><goal>clean</goal></goals></execution></executions></plugin></plugins></build>

插件介紹

maven-jar-plugin

https://maven.apache.org/plugins/maven-jar-plugin/

在這里插入圖片描述

maven-jar-plugin 是 Maven 的一個插件,用于創建 JAR 文件。它可以將項目的源代碼、依賴項和配置文件打包成一個 JAR 文件,以便在應用程序中使用。該插件使用 Apache Maven 的默認構建系統,因此可以使用 Maven 的所有功能,如依賴項管理、構建腳本等。

使用 maven-jar-plugin 的主要優點是可以輕松地創建 JAR 文件,而不必手動編寫 Ant 腳本或使用其他工具。此外,該插件還支持一些高級功能,如資源過濾、代碼混淆和 Javadoc 文檔生成等。這些功能可以使 JAR 文件更加強大和易于使用。

maven-jar-plugin 通常與 Maven 的其他插件一起使用,如 maven-compiler-plugin 和 maven-resources-plugin,以構建復雜的應用程序。例如,可以使用 maven-jar-plugin 將編譯后的源代碼打包成 JAR 文件,并使用 maven-resources-plugin 將資源文件打包成 JAR 文件。

這些插件可以一起使用,以構建具有各種功能和依賴項的應用程序。

假設我們要創建一個名為my-project的 JAR 文件,其中包含項目中的源代碼、依賴項和一些資源文件。我們可以使用 maven-jar-plugin 來完成這個任務。以下是一個具體的使用案例:

  1. 首先,在 Maven 項目中添加 maven-jar-plugin 插件。在pom.xml文件中的<build>標簽內添加以下內容:
<build>  <plugins>  <plugin>  <groupId>org.apache.maven.plugins</groupId>  <artifactId>maven-jar-plugin</artifactId>  <version>3.2</version>  <executions>  <execution>  <goals>  <goal>jar</goal>  </goals>  </execution>  </executions>  </plugin>  </plugins>  
</build>  
  1. 配置maven-jar-plugin的參數。在<execution>標簽內,我們可以添加以下內容:
<execution>  <goals>  <goal>jar</goal>  </goals>  <configuration>  <artifactId>my-project</artifactId>  <version>1.0</version>  <includes>  <include>src/main/java/**</include>  <include>src/main/resources/**</include>  </includes>  </configuration>  
</execution>  

在這個例子中,我們設置了artifactIdmy-projectversion1.0。此外,我們還指定了要包含的源代碼和資源文件的路徑。

  1. 執行 Maven 構建。在項目根目錄下運行以下命令:
mvn clean package  

這將清理項目目錄并構建 JAR 文件。

  1. 查看生成的 JAR 文件。在target目錄下,你應該會看到生成的my-project-1.0.jar文件。
    通過這個案例,我們已經成功地使用 maven-jar-plugin 創建了一個 JAR 文件,其中包含項目的源代碼和資源文件。這個例子展示了如何簡單地使用 maven-jar-plugin 來打包 Maven 項目。在實際項目中,你可能還需要配置其他參數以滿足不同的需求。

看個 nacos的類似的配置
在這里插入圖片描述
這段代碼是在pom.xml中的<build>標簽內添加了一個maven-jar-plugin插件的配置。以下是各個部分的解釋:

  1. <plugin>:開始定義一個插件。
  2. <artifactId>maven-jar-plugin</artifactId>:指定插件的 artifactId 為 maven-jar-plugin`。
  3. <configuration>:開始定義插件的配置。
  4. <archive>:開始定義歸檔(archive)配置。
  5. <manifest>:開始定義 manifest 配置。
  6. <addDefaultImplementationEntries>true</addDefaultImplementationEntries>:設置為 true以在 manifest 中添加默認實現入口。這將告訴 Java 運行時使用指定的類(通常是main` 類)作為應用程序的入口點。
  7. <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>:設置為 true以在 manifest 中添加默認規范入口。這將告訴 Java 運行時使用指定的類(通常是main` 類)作為應用程序的入口點,同時還會添加一些額外的規范信息。
  8. :結束 manifest 配置。
  9. :結束歸檔(archive)配置。
  10. :結束插件的配置。
  11. :結束插件的定義。

這個插件配置的主要目的是設置 JAR 文件的 manifest,以便在運行時使用指定的類作為應用程序的入口點。通過添加默認實現入口和默認規范入口,可以確保應用程序能夠正確地運行并提供一些額外的規范信息。這通常用于創建可執行 JAR 文件,其中包含應用程序的主類。

再看個類似的配置

<plugin>  <groupId>org.apache.maven.plugins</groupId>  <artifactId>maven-jar-plugin</artifactId>  <version>2.3.1</version>  <configuration>  <archive>  <manifest>  <mainClass>com.artisan.MyTest</mainClass> <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries><addDefaultImplementationEntries>true</addDefaultImplementationEntries> </manifest><!-- 配置額外屬性信息 --><manifestEntries>  <Plugin-Id>demo-plugin</Plugin-Id>  <Plugin-Version>1.0.0</Plugin-Version>  </manifestEntries>  </archive>  </configuration>  
</plugin> 

在之前的工程 POM 文件中添加上述構建插件重新進行打包,可以看到 MANIFEST.MF 文件中即添加了我們配置的額外屬性。

Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven
Built-By: great
Build-Jdk: 1.8.0_202
# Specification entries
Specification-Title: maven-v1
Specification-Version: 1.0-SNAPSHOT
# Implementation entries
Implementation-Title: maven-v1
Implementation-Version: 1.0-SNAPSHOT
Implementation-Vendor-Id: com.artisan
# Manifest
Main-Class: com.artisan.MyTest
# ManifestEntries
Plugin-Id: demo-plugin
Plugin-Version: 1.0.0

maven-assembly-plugin

https://maven.apache.org/plugins/maven-assembly-plugin/
在這里插入圖片描述

https://maven.apache.org/plugins/maven-assembly-plugin/examples/index.html

在這里插入圖片描述

在普通 Maven 工程打包時默認僅會編譯工程中新建的 java 文件并存儲其 .class 文件,對于 POM 文件中引用的第三方依賴并不會一同打包。

如新建一個 Maven 工程并在依賴中導入 Jackson 依賴庫并進行打包編譯,可以看到下圖編譯后的 JAR 文件中只有工程中新建的 MyTest.class 文件,項目中所導入的依賴并沒有被一起打包 .

在這里插入圖片描述

而通過 assembly 插件即可將 POM 配置中的所有依賴一同打包編譯至 JAR 文件中。

其中 execution 標簽定義了 assembly 插件的作用階段,如這里設置了在 Maven package 即打包階段生效

<plugin>  <groupId>org.apache.maven.plugins</groupId>  <artifactId>maven-assembly-plugin</artifactId>  <version>3.1.0</version>  <configuration>  <descriptorRefs>  <descriptorRef>jar-with-dependencies</descriptorRef>  </descriptorRefs>  <!-- Set jar file name --><finalName>${project.artifactId}-${project.version}-all</finalName>  <appendAssemblyId>false</appendAssemblyId>  <attach>false</attach>  <archive>  <manifest>  <mainClass>fully.qualified.MainClass</mainClass> <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries><addDefaultImplementationEntries>true</addDefaultImplementationEntries> </manifest>   </archive>  </configuration>  <executions>  <execution>  <!-- Set effect phase --><id>make-assembly</id>  <phase>package</phase>  <goals>  <goal>single</goal>  </goals>  </execution>  </executions>  
</plugin>

在工程 POM 配置中添加上述信息并重新編譯打包工程,可以看到此時 JAR 文件中除了自定義創建的 MyTest.clss 文件外同時包含了依賴的第三方庫。

在這里插入圖片描述


另外一個Demo : Creating fat JARs using the Maven Assembly plugin

  1. Go to the pom.xml file and make sure the main application class is specified:
<properties><main.class>com.example.ApplicationKt</main.class>
</properties>
  1. If you use EngineMain without the explicit main function, the application’s main class depends on the used engine and might look as follows: io.ktor.server.netty.EngineMain.

Add maven-assembly-plugin to the plugins block as follows:

<plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-assembly-plugin</artifactId><version>2.6</version><configuration><descriptorRefs><descriptorRef>jar-with-dependencies</descriptorRef></descriptorRefs><archive><manifest><addClasspath>true</addClasspath><mainClass>${main.class}</mainClass></manifest></archive></configuration><executions><execution><id>assemble-all</id><phase>package</phase><goals><goal>single</goal></goals></execution></executions>
</plugin>
  1. Build an assembly

To build an assembly for the application, open the terminal and execute the following command:

mvn package

When this build completes, you should see the tutorial-server-get-started-maven-0.0.1-jar-with-dependencies.jar file in the target directory.

  1. Run the application

To run the built application:

Open the terminal and execute the following command to run the application:

java -jar target/tutorial-server-get-started-maven-0.0.1-jar-with-dependencies.jar

Wait until the following message is shown:

[main] INFO  Application - Responding at http://0.0.0.0:8080

You can click the link to open the application in a default browser:

在這里插入圖片描述


maven-shade-plugin

https://maven.apache.org/plugins/maven-shade-plugin/

在這里插入圖片描述

Shade 插件的功能更為強大,其提供了兩個功能:

  • 第一個即與 assembly 類似可實現依賴的打包編譯,與 assembly 不同的是 Shade 提供了更靈活的執行策略,可指定需要打包編譯的依賴集合。

  • 另一個即實現包的重命名功能,我們都知道 Maven 并不允許在一共工程中同時引入單個依賴的不同版本,而通過 Shade 插件即可實現二次包裝從而繞開該限制。

Shade 插件 - 標簽

下面介紹一下 Shade 插件中各標簽的使用。

artifactSet

通過 includes 標簽可以指定需要一同打包編譯的第三方依賴。

定義的格式為:groupId:artifactId。

<artifactSet>  <includes>  <include>groupId:artifactId</include>  </includes>  
</artifactSet>  

relocations

通過 relocations 標簽即可實現模塊的重命名功能。

其中 pattern 為需要重命名的模塊包, shadedPattern 為重命名后的模塊名。

<relocations>  <relocation>  <pattern>old.package.name</pattern>  <shadedPattern>new.package.name</shadedPattern>  </relocation>
</relocations>  

filters

通過 filters 標簽可以實現非必要文件的排除,如常見的協議文件等,可通過文件名或類型實現匹配。

<filters>  <filter>  <artifact>*:*</artifact>  <excludes>  <exclude>filename</exclude>  <exclude>file pattern</exclude>  </excludes>  </filter>  
</filters>  

完整配置

Shade 同樣可以通過 execution 設置作用階段,上述介紹標簽的完整配置內容如下:

<plugins>  <plugin>  <groupId>org.apache.maven.plugins</groupId>  <artifactId>maven-shade-plugin</artifactId>  <version>3.2.0</version>  <executions>  <!-- Working phase -->  <execution>  <phase>package</phase>  <goals>  <goal>shade</goal>  </goals>  </execution>  </executions>  <configuration>  <minimizeJar>true</minimizeJar>  <!-- Defined what dependencies to pull into the uber JAR -->  <artifactSet>  <includes>  <include>com.fasterxml.jackson.core:jackson-core</include>  </includes>  </artifactSet>  <!-- Rename the package -->  <relocations>  <relocation>  <!-- Old name -->  <pattern>com.fasterxml.jackson.core</pattern>  <!-- New name -->  <shadedPattern>com.ibudai.fasterxml.jackson.core</shadedPattern>  </relocation>   </relocations>  <!-- Exclude the file that didn't want -->  <filters>  <filter>  <artifact>*:*</artifact>  <excludes>  <exclude>META-INF/license/**</exclude>  <exclude>META-INF/*</exclude>  <exclude>LICENSE</exclude>  <exclude>NOTICE</exclude>  </excludes>  </filter>  </filters>  </configuration>  </plugin>  
</plugins>

在之前的工程中添加上述配置并重新打包,可以看到編譯后的 Jackson 模塊包層級已經變成我們自定義的內容,而 Java 的類加載即通過類的完成限定名(包名+類名)來區分是否為同一個類,因此通過 Shade 插件即可實現 Maven 的單一工程多版本引入。

在這里插入圖片描述
官方文檔

https://maven.apache.org/plugins/maven-shade-plugin/examples/class-relocation.html

在這里插入圖片描述
在這里插入圖片描述

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

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

相關文章

零食量販店熱潮:小縣城的新零售革命

零食量販店熱潮&#xff1a;小縣城的新零售革命 目錄 引言零食量販店的快速崛起零食量販店的運營模式量販零食店在小縣城的影響技術在零食量販店的應用未來展望結論 1. 引言 近年來&#xff0c;零食量販店在我國小縣城迅速發展&#xff0c;成為一種新型的零售模式。在一條街…

flutter 二進制轉字符串

通常接口返回的數據都是二進制數據 二進制轉字符串&#xff1a;utf8二進制轉字符串 onRoomMsg.body是二進制編碼 utf8.decode(onRoomMsg.body)然后字符串轉對象 json.decode(utf8.decode(onRoomMsg.body))然后再用fromJson解析 PrankActivityModel prankActivityModel Prank…

新疆大學841軟件工程考研

1&#xff0e;軟件生產的發展經歷了三個階段&#xff0c;分別是____、程序系統時代和軟件工程時代時代。 2&#xff0e;可行性研究從以下三個方面研究每種解決方法的可行性&#xff1a;經濟可行性、社會可行性和_____。 3&#xff0e;HIPO圖的H圖用于描述軟件的層次關系&…

Android 12.0 系統systemui下拉通知欄的通知布局相關源碼分析

1.前言 在android12.0的系統rom開發中,在進行systemui中的下拉通知欄的布局自定義的時候,對于原生systemui的 系統的下拉通知欄的通知布局的了解也是非常重要的,接下來就來分析下相關的下拉通知欄的通知布局的相關 源碼流程,了解這些才方便對通知欄的布局做修改 2.系統sy…

創建maven的Springboot項目出現錯誤:Cannot access alimaven

創建maven的Springboot項目出現錯誤&#xff1a;Cannot access alimaven 1&#xff09;問題2) 分析問題3&#xff09;解決問題 1&#xff09;問題 創建maven的Springboot項目出現錯誤&#xff1a; Cannot access alimaven (http://maven.aliyun.com/nexus/content/groups/p…

“深入探索JVM內部機制:解密Java虛擬機的工作原理“

標題&#xff1a;深入探索JVM內部機制&#xff1a;解密Java虛擬機的工作原理 摘要&#xff1a;本文將深入探索Java虛擬機&#xff08;JVM&#xff09;的內部機制&#xff0c;解密其工作原理。我們將介紹JVM的基本組成部分、類加載過程、內存管理和垃圾回收、即時編譯器等關鍵概…

Linux C++ 網絡編程基礎(2) : TCP多線程一個server對應多個client

目錄 一、linux posix線程相關函數介紹二、tcp server基礎版本三、tpc服務端多線程版本四、tpc客戶端代碼tcp編程時, 一個server可以對應多個client, server端用多線程可以實現. linux下多線程可以使用POSIX的線程函數, 下面給出服務端和客戶端的代碼. 一、linux posix線程相關…

RocketMQ 單機源碼部署 自定義配置文件和端口以及acl權限配置解析

思路 1、我們首先配置完 namesrv和broker和acl認證的配置文件&#xff0c;然后直接使用-c指定配置文件來啟動程序&#xff0c;就會非常明了&#xff0c;用戶名密碼要大于6&#xff0c;第一個用戶我測試著不知道為什么始終有最高權限&#xff0c;大家盡量不要吧第一個用戶給別人…

Redis輔助功能

一、Redis隊列 1.1、訂閱 subscribe ch1 ch2 1.2 publish:發布消息 publish channel message 1.3 unsubscribe: 退訂 channel 1.4 模式匹配 psubscribe ch* 模糊發布&#xff0c;訂閱&#xff0c;退訂&#xff0c; p* <channelName> 1.5 發布訂閱原理 訂閱某個頻道或…

05-基礎入門-系統及數據庫等

基礎入門-系統及數據庫等 一、操作系統層面1、識別操作系統常見方法2、簡要兩者區別及識別意義3、操作系統層面漏洞類型對應意義4、簡要操作系統層面漏洞影響范圍 二、數據庫層面1、識別數據庫類型常見方法2、數據庫類型區別及識別意義3、數據庫常見漏洞類型及攻擊4、簡要數據庫…

word在頁眉頁腳添加第幾頁

如果直接在頁腳添加數字&#xff0c;整個文檔的頁腳會是統一的。 這里我們需要的是每一頁按照頁碼排布的文檔&#xff0c;所以首先打開頁腳設置&#xff1a; 在插入內選擇頁腳 在彈出的下拉窗口中選擇空白即可 在菜單欄會多出“頁眉和頁腳”的選項卡&#xff0c;選擇其中的頁…

【CTFshow】——PWN簽到題

文章目錄 一【題目環境】二【題目類別】三【題目編號】四【題目描述】五【解題思路】六【解題過程】七【提交結果】 一【題目環境】 名稱版本Ubuntu系統22.04.1 LTSLinux內核5.15.0-43-generic 二【題目類別】 此題無特殊類別&#xff0c;為入門題 三【題目編號】 PWN簽到…

數字孿生:Three.js(WebGL)和虛擬引擎

一、先說總結 總的來說&#xff0c;選擇Three.js和WebGL還是虛擬引擎&#xff0c;主要取決于你的項目需求和優先級。 如果你的數字孿生項目主要是為了Web展示&#xff0c;需要快速加載&#xff0c;且對3D效果和物理模擬的需求不高&#xff0c;那么Three.js是一個非常好的選擇。…

gstreamer rtsp server 在ubuntu系統上的安裝

gstreamer rtsp server 在ubuntu系統上的安裝 本篇博客介紹gstreamer rtsp server在ubuntu系統上的安裝 python python直接使用pip安裝 sudo apt install gir1.2-gst-rtsp-server-1.0C 安裝 下載源碼 git clone https://github.com/GStreamer/gst-rtsp-server.git進入倉…

supOS APP開發者課程練習冊創建服務(命名:getPropertiesHistory)

創建服務&#xff08;命名&#xff1a;getPropertiesHistory&#xff09;,調用getPropertiesHistory()服務&#xff0c;獲取“催化裂化一車間”對象的“重質餾分油_進”最近5分鐘內的歷史值&#xff0c;每一分鐘取一個值&#xff0c;開始時間和結束時間需要調用時間格式化功能集…

【2022吳恩達機器學習課程視頻翻譯筆記】3.3代價函數公式

忙了一陣子&#xff0c;回來繼續更新 3.3 代價函數公式 In order to implement linear regression. The first key step is first to define something called a cost function. This is something we’ll build in this video, and the cost function will tell us how well…

Redis專題-隊列

Redis專題-隊列 首先&#xff0c;想一想 Redis 適合做消息隊列嗎&#xff1f; 1、消息隊列的消息存取需求是什么&#xff1f;redis中的解決方案是什么&#xff1f; 無非就是下面這幾點&#xff1a; 0、數據可以順序讀取 1、支持阻塞等待拉取消息 2、支持發布/訂閱模式 3、重…

前后端分離------后端創建筆記(09)密碼加密網絡安全

本文章轉載于【SpringBootVue】全網最簡單但實用的前后端分離項目實戰筆記 - 前端_大菜007的博客-CSDN博客 僅用于學習和討論&#xff0c;如有侵權請聯系 源碼&#xff1a;https://gitee.com/green_vegetables/x-admin-project.git 素材&#xff1a;https://pan.baidu.com/s/…

數據庫概述、部署MySQL服務、必備命令、密碼管理、安裝圖形軟件、SELECT語法 、篩選條件

Top NSD DBA DAY01 案例1&#xff1a;構建MySQL服務器案例2&#xff1a;密碼管理案例3&#xff1a;安裝圖形軟件案例4&#xff1a;篩選條件 1 案例1&#xff1a;構建MySQL服務器 1.1 問題 在IP地址192.168.88.50主機和192.168.88.51主機上部署mysql服務練習必備命令的使用 …

代理模式概述

1.代理模式概述 學習內容 1&#xff09;概述 為什么要有 “代理” &#xff1f; 生活中就有很多例子&#xff0c;比如委托業務&#xff0c;黃牛&#xff08;票販子&#xff09;等等代理就是被代理者沒有能力或者不愿意去完成某件事情&#xff0c;需要找個人代替自己去完成這…