当前位置: 首页 > news >正文

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

在这里插入图片描述
在这里插入图片描述

相关文章:

Maven - 统一构建规范:Maven 插件管理最佳实践

文章目录 Available Plugins开源项目中的使用插件介绍maven-jar-pluginmaven-assembly-pluginmaven-shade-pluginShade 插件 - 标签artifactSetrelocationsfilters 完整配置 Available Plugins https://maven.apache.org/plugins/index.html Maven 是一个开源的软件构建工具&…...

对接海康明眸门禁设备-删除人员信息

对接海康明眸门禁设备-删除人员信息 文中登录 退出登录 长连接和海康hCNetSDK等接口 见文章 初始SDK和登录 /*** 删除人脸 IotCommDataResult 自定义类 收集结果*/Overridepublic List<IotCommDataResult> deleteFace(IotCameraParam camera, Collection<Long> us…...

LEADTOOLS Imaging SDK Crack

LEADTOOLS Imaging SDK Crack 高级开发人员工具包包括ActiveX和WPF/XAML控件。 LEADTOOLS Imaging SDK为文件格式导入/导出、图像压缩、图像显示和效果、颜色转换、图像处理、TWAIN扫描、图像通用对话框、数据库集成、打印和互联网提供了基本和高级的彩色图像功能。 LEADTOOLS …...

2023并发之八股文——面试题

基础知识 并发编程的优缺点为什么要使用并发编程&#xff08;并发编程的优点&#xff09; 充分利用多核CPU的计算能力&#xff1a;通过并发编程的形式可以将多核CPU 的计算能力发挥到极致&#xff0c;性能得到提升方便进行业务拆分&#xff0c;提升系统并发能力和性能&#x…...

操作记录日志保存设计实现

定义一个切面类 @Aspect @Slf4j @Component @RequiredArgsConstructor public class OperateLogAopConfig {private final ISysOperateLogService sysOperateLogService;@Around("@annotation(operateLog)")public Object operateLog(ProceedingJoinPoint point, Op…...

PL 侧驱动和fpga 重加载的方法

可以解决很多的问题 时钟稳定后加载特定fpga ip &#xff08;要不内核崩的一塌糊涂&#xff09;fpga 稳定复位软件决定fpga ip 加载的时序 dluash load /usr/local/scripts/si5512_setup.lua usleep 30 mkdir -p /lib/firmware cp -rf /usr/local/firmare/{*.bit.bin,*.dtbo} …...

【2023最新爬虫】用python爬取知乎任意问题下的全部回答

老规矩&#xff0c;先上结果&#xff1a; 爬取了前200多页&#xff0c;每页5条数据&#xff0c;共1000多条回答。&#xff08;程序设置的自动判断结束页&#xff0c;我是手动break的&#xff09; 共爬到13个字段&#xff0c;包含&#xff1a; 问题id,页码,答主昵称,答主性别,…...

Bingchat和ChatGPT主要区别

Bing Chat由chatgpt GPT-4技术提供支持&#xff0c;这是流行的ChatGPT的最新语言模型。Bing Chat通过更具交互性和上下文联动的响应来优化搜索引擎。它允许用户提出问题并获得更人性化、精确化或创造力的答案。用户还可以在答案末尾查看的参考来源。该工具可以充当个人研究、计…...

Docker容器:docker镜像的创建及dockerfile

Docker容器&#xff1a;docker镜像的创建及dockerfile案例 一.docker镜像的三种创建方法 创建镜像有三种方法&#xff1a;基于现有镜像创建、基于本地模板创建及基于dockerfile创建 1.基于现有镜像创建 1.1 启动镜像 #首先启动一个镜像&#xff0c;在容器里做修改 docker …...

Vue3 父子组件数据传递

1、父组件向子组件传递数据 1.1、传递多个简单变量给到子组件 父组件使用 <TitleView title"标题" :name"name" :isCollect"isCollect" collect-event"collectEvent" /><script setup>const name ref(名字)const isCol…...

Eureka:集群环境配置

创建三个集群 导包 <!-- 导包--><dependencies><!-- Eureka -server --><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-eureka-server</artifactId><version>1.…...

springboot之多数据源配置

文章目录 一、多数据源的典型使用场景1 业务复杂&#xff08;数据量大&#xff09;2 读写分离 二、如何实现多数据源通过AbstractRoutingDataSource动态指定数据源多数据源切换方式AOPMyBatis插件 三、spring集成多个Mybatis框架 实现多数据源控制四、dynamic-datasource 多数据…...

无涯教程-PHP - 静态变量函数

静态变量 静态变量在函数退出时值不会丢失,您只需将关键字STATIC放在变量名称的前面,即可将变量声明为静态变量。 <?phpfunction keep_track() {STATIC $count0;$count;print $count;print "<br />";}keep_track();keep_track();keep_track(); ?> 这…...

2023-08-20力扣今日二题

链接&#xff1a; 1312. 让字符串成为回文串的最少插入次数 题意&#xff1a; 如题 解&#xff1a; 动态规划&#xff0c;枚举回文串中点并递增回文串长度 初始状态若LR则单个字符为中点&#xff0c;需要添加0个字符成为回文串&#xff1b;若L1R则如果S[L]S[R]则需要添加…...

【地理专题】2023年最新全国A级景区数

数据来源&#xff1a;中国文化和旅游部时间跨度&#xff1a;2023年区域范围&#xff1a;全国范围数据字段&#xff1a; 景区名称&#xff1b;地址&#xff1b;等级&#xff1b;城市&#xff1b;经度&#xff1b;纬度 该图基于自然资源部地图技术审查中心标准地图服务网站下载…...

Elasticsearch实战(一):Springboot实现Elasticsearch统一检索功能

文章目录 系列文章索引一、准备工作1、搭建docker环境2、安装eskibana3、es安装ik分词器&#xff08;1&#xff09;下载安装&#xff08;2&#xff09;测试 4、Springboot&#xff08;1&#xff09;引包&#xff08;2&#xff09;客户端公共方法&#xff08;3&#xff09;公共实…...

更改计算机睡眠时间

控制面板–>系统和安全–>电源选项下的更改计算机睡眠时间 如果关闭显示器时间小于使计算机进入睡眠状态时间&#xff0c;时间先到达关闭显示器时间&#xff0c;显示器关闭&#xff0c;这时电脑还在正常工作状态。如果此时敲击键盘显示器出现画面&#xff0c;无需输入密…...

Matplotlib数据可视化(一)

目录 1.Matplotlib简介 2.Matplotlib绘图基础 2.1 创建画布与子图 2.2 添加画布属性 2.3 绘图的保存与显示 1.Matplotlib简介 Matplotlib是一个用于绘制数据可视化图表的Python库。它提供了广泛的功能和灵活性&#xff0c;可以创建各种类型的图表&#xff0c;包括折线图、…...

LLM提示词工程和提示词工程师Prompting and prompt engineering

你输入模型的文本被称为提示&#xff0c;生成文本的行为被称为推断&#xff0c;输出文本被称为完成。用于提示的文本或可用的内存的全部量被称为上下文窗口。尽管这里的示例显示模型表现良好&#xff0c;但你经常会遇到模型在第一次尝试时无法产生你想要的结果的情况。你可能需…...

Python开发环境(Visual Studio Code、Anaconda、PyInstaller、Enigma Virtual Box)

Python开发环境 [Anaconda、PyInstaller、Enigma Virtual Box] AnacondaAnaconda安装搭建Python环境Anaconda命令 Visual Studio CodeVisual Studio Code中Python设置Visual Studio Code中使用Qt Designer Python打包发布.exe可执行文件PyinstallerEnigma Virtual Box Anaconda…...

大数据学习栈记——Neo4j的安装与使用

本文介绍图数据库Neofj的安装与使用&#xff0c;操作系统&#xff1a;Ubuntu24.04&#xff0c;Neofj版本&#xff1a;2025.04.0。 Apt安装 Neofj可以进行官网安装&#xff1a;Neo4j Deployment Center - Graph Database & Analytics 我这里安装是添加软件源的方法 最新版…...

shell脚本--常见案例

1、自动备份文件或目录 2、批量重命名文件 3、查找并删除指定名称的文件&#xff1a; 4、批量删除文件 5、查找并替换文件内容 6、批量创建文件 7、创建文件夹并移动文件 8、在文件夹中查找文件...

【大模型RAG】Docker 一键部署 Milvus 完整攻略

本文概要 Milvus 2.5 Stand-alone 版可通过 Docker 在几分钟内完成安装&#xff1b;只需暴露 19530&#xff08;gRPC&#xff09;与 9091&#xff08;HTTP/WebUI&#xff09;两个端口&#xff0c;即可让本地电脑通过 PyMilvus 或浏览器访问远程 Linux 服务器上的 Milvus。下面…...

在Ubuntu中设置开机自动运行(sudo)指令的指南

在Ubuntu系统中&#xff0c;有时需要在系统启动时自动执行某些命令&#xff0c;特别是需要 sudo权限的指令。为了实现这一功能&#xff0c;可以使用多种方法&#xff0c;包括编写Systemd服务、配置 rc.local文件或使用 cron任务计划。本文将详细介绍这些方法&#xff0c;并提供…...

uniapp中使用aixos 报错

问题&#xff1a; 在uniapp中使用aixos&#xff0c;运行后报如下错误&#xff1a; AxiosError: There is no suitable adapter to dispatch the request since : - adapter xhr is not supported by the environment - adapter http is not available in the build 解决方案&…...

AspectJ 在 Android 中的完整使用指南

一、环境配置&#xff08;Gradle 7.0 适配&#xff09; 1. 项目级 build.gradle // 注意&#xff1a;沪江插件已停更&#xff0c;推荐官方兼容方案 buildscript {dependencies {classpath org.aspectj:aspectjtools:1.9.9.1 // AspectJ 工具} } 2. 模块级 build.gradle plu…...

Reasoning over Uncertain Text by Generative Large Language Models

https://ojs.aaai.org/index.php/AAAI/article/view/34674/36829https://ojs.aaai.org/index.php/AAAI/article/view/34674/36829 1. 概述 文本中的不确定性在许多语境中传达,从日常对话到特定领域的文档(例如医学文档)(Heritage 2013;Landmark、Gulbrandsen 和 Svenevei…...

VM虚拟机网络配置(ubuntu24桥接模式):配置静态IP

编辑-虚拟网络编辑器-更改设置 选择桥接模式&#xff0c;然后找到相应的网卡&#xff08;可以查看自己本机的网络连接&#xff09; windows连接的网络点击查看属性 编辑虚拟机设置更改网络配置&#xff0c;选择刚才配置的桥接模式 静态ip设置&#xff1a; 我用的ubuntu24桌…...

A2A JS SDK 完整教程:快速入门指南

目录 什么是 A2A JS SDK?A2A JS 安装与设置A2A JS 核心概念创建你的第一个 A2A JS 代理A2A JS 服务端开发A2A JS 客户端使用A2A JS 高级特性A2A JS 最佳实践A2A JS 故障排除 什么是 A2A JS SDK? A2A JS SDK 是一个专为 JavaScript/TypeScript 开发者设计的强大库&#xff…...

08. C#入门系列【类的基本概念】:开启编程世界的奇妙冒险

C#入门系列【类的基本概念】&#xff1a;开启编程世界的奇妙冒险 嘿&#xff0c;各位编程小白探险家&#xff01;欢迎来到 C# 的奇幻大陆&#xff01;今天咱们要深入探索这片大陆上至关重要的 “建筑”—— 类&#xff01;别害怕&#xff0c;跟着我&#xff0c;保准让你轻松搞…...