网站架构图用什么做,sem 优化价格,网站备案 拍照网点,网站开发程序员的工资是多少1.spring-boot-maven-plugin
我们直接使用 maven package #xff08;maven自带的package打包功能#xff09;#xff0c;打包Jar包的时候#xff0c;不会将该项目所依赖的Jar包一起打进去#xff0c;在使用java -jar命令启动项目时会报错#xff0c;项目无法正常启动。…1.spring-boot-maven-plugin
我们直接使用 maven package maven自带的package打包功能打包Jar包的时候不会将该项目所依赖的Jar包一起打进去在使用java -jar命令启动项目时会报错项目无法正常启动。这个时候我们就可以考虑引用spring-boot-maven-plugin插件来为项目打Jar包。
plugingroupIdorg.springframework.boot/groupIdartifactIdspring-boot-maven-plugin/artifactIdversion${spring.boot.version}/versionexecutionsexecutiongoals!-- 将引入的 jar 打入其中 --goalrepackage/goal/goals/execution/executions
/plugin2.flatten-maven-plugin
在使用Maven多模块结构工程时版本管理是一件很繁琐且容易出错的事情。每次升级版本号都要手动调整或者通过mvn versions:set -DnewVerion1.2.0-SNAPSHOT命令去更改每一个子模块的版本号非常的不方便Maven官方文档说自 Maven 3.5.0-beta-1 开始可以使用 ${revision}, ${sha1} and/or ${changelist} 这样的变量作为版本占位符。即在maven多模块项目中可配合插件flatten-maven-plugin及${revision}属性来实现全局版本统一管理。
!-- 统一 revision 版本 --
plugingroupIdorg.codehaus.mojo/groupIdartifactIdflatten-maven-plugin/artifactIdversion1.5.0/versionconfiguration!-- 避免IDE将 .flattened-pom.xml 自动识别为功能模块 --flattenModeresolveCiFriendliesOnly/flattenModeupdatePomFiletrue/updatePomFile/configurationexecutionsexecutiongoalsgoalflatten/goal/goalsidflatten/idphaseprocess-resources/phase/executionexecutiongoalsgoalclean/goal/goalsidflatten.clean/idphaseclean/phase/execution/executions
/plugin不可混合使用${revision}和明确字符串版本号若出现父子模块版本号混合使用${revision}和明确字符串形式如1.2.0-SNAPSHOT在mvn package会出现类似如下错误 3.maven-clean-plugin
maven-clean-plugin 插件对应的命令是 mvn clean执行 mvn clean 命令会删除构建输出目录 target。mvn clean 命令其实是调用 maven-clean-plugin 插件执行 clean 操作的。maven-clean-plugin 插件是默认安装好的插件并不需要我们在 pom.xml 文件中进行配。
plugingroupIdorg.apache.maven.plugins/groupIdartifactIdmaven-clean-plugin/artifactIdversion3.2.0/versionconfiguration!-- 忽略错误 --failOnErrorfalse/failOnError/configuration!-- mvn package和mvn clean package等价配置 --executionsexecutionidauto-clean/idphaseinitialize/phasegoalsgoalclean/goal/goals/execution/executions
/plugin4.maven-compiler-plugin
maven-compiler-plugin 插件是一个 Maven 插件用来编译项目代码自从3.0开始默认的编译器是 javax.tools.JavaCompiler用来编译 Java 源码如果你想强制插件使用 javac 编译器你必须配置插件的属性 forceJavacCompilerUse还要注意当前默认源source设置为 1.6默认目标(target)设置为 1.6。独立运行 Maven 和 JDK可以通过 source 和 target 选项更改他们的默认值
plugingroupIdorg.apache.maven.plugins/groupIdartifactIdmaven-compiler-plugin/artifactIdversion3.8.1/versionconfiguration!-- 源代码使用的JDK版本 --source1.8/source !-- 需要生成的目标class文件的编译版本 --target1.8/target !-- 字符集编码 --encodingUTF-8/encoding!-- 跳过测试 --skipTeststrue/skipTests!-- maven-compiler-plugin 插件解决 Lombok MapStruct 组合 --annotationProcessorPathspathgroupIdorg.springframework.boot/groupIdartifactIdspring-boot-configuration-processor/artifactIdversion2.7.18/version/pathpathgroupIdorg.projectlombok/groupIdartifactIdlombok/artifactIdversion1.18.30/version/pathpathgroupIdorg.mapstruct/groupIdartifactIdmapstruct-processor/artifactIdversion1.5.5.Final/version/path/annotationProcessorPaths/configuration
/plugin5.maven-resources-plugin
maven-resources-plugin插件来将src/main/resources目录中的资源文件单独剥离出来生成一个独立的资源文件包用于处理项目资源文件并拷贝到输出目录。
plugingroupIdorg.apache.maven.plugins/groupIdartifactIdmaven-resources-plugin/artifactIdversion3.2.0/versionexecutionsexecutionidcopy-resources/idphasepackage/phasegoalsgoalcopy-resources/goal/goalsconfigurationoutputDirectory${project.build.directory}/resources/outputDirectoryresourcesresourcedirectorysrc/main/resources/directoryincludesinclude**/*/include/includes/resource/resources/configuration/execution/executions/plugin上述配置将在Maven的package阶段执行copy-resources目标并将src/main/resources目录中的所有文件复制到${project.build.directory}/resources目录下。执行mvn package命令后将生成一个独立的资源文件包其中包含src/main/resources目录中的所有文件。可以在${project.build.directory}/resources目录中找到这个资源文件包。
6.maven-source-plugin
maven-source-plugin提供项目自动将源码打包并发布的功能在需要发布源码项目的pom.xml文件中添加如下代码即可执行 mvn installmaven会自动将source install到repository 。执行 mvn deploymaven会自动将source deploy到remote-repository 。执行 mvn source:jar单独打包源码。
plugingroupIdorg.apache.maven.plugins/groupIdartifactIdmaven-source-plugin/artifactIdversion3.3.0/versionexecutionsexecutionidattach-sources/idgoalsgoaljar/goal/goals/execution/executions
/plugin7.maven-war-plugin
maven-war-pluginWAR 插件负责收集 Web 应用程序的所有依赖项、类和资源并将它们打包到 WAR 包中仅包含 scope 为 compileruntime 的依赖项默认绑定到 package 阶段。
pluginsplugingroupIdorg.apache.maven.plugins/groupIdartifactIdmaven-war-plugin/artifactIdversion3.4.0/version/plugin
/plugins
resourcesresourcedirectorysrc/main/java/directoryincludesinclude**/*.xml/include/includesfilteringfalse/filtering/resourceresourcedirectorysrc/main/resources/directoryincludesinclude**/**/include/includesfilteringtrue/filtering/resource
/resources8.maven-antrun-plugin
maven-antrun-plugin 是 Maven 的一个插件它允许你在 Maven 构建生命周期的某个阶段执行 Apache Ant 任务。Apache Ant 是一个基于 Java 的构建工具常用于 Java 项目的构建和部署。
plugingroupIdorg.apache.maven.plugins/groupIdartifactIdmaven-antrun-plugin/artifactIdversion3.1.0/version
/plugin9.maven-surefire-plugin
Maven本身并不是一个单元测试框架它只是在构建执行到特定生命周期阶段的时候通过插件来执行JUnit或者TestNG的测试用例。这个插件就是maven-surefire-plugin也可以称为测试运行器(Test Runner)它能兼容JUnit]3、JUnit 4以及TestNG。
plugingroupIdorg.apache.maven.plugins/groupIdartifactIdmaven-surefire-plugin/artifactIdversion3.0.0-M5/version
/plugin10.versions-maven-plugin
versions-maven-plugin插件可以管理项目版本 特别是当Maven工程项目中有大量子模块时可以批量修改pom版本号插件会把父模块更新到指定版本号然后更新子模块版本号与父模块相同可以避免手工大量修改和遗漏的问题。
!-- generateBackupPoms为true默认值pom.xml.versionsBackup备份文件否则没有备份文件无法回退版本号 --
plugin groupIdorg.codehaus.mojo/groupId artifactIdversions-maven-plugin/artifactId version2.7/versionconfigurationgenerateBackupPomstrue/generateBackupPoms/configuration
/plugin#查看版本号
mvn help:evaluate -Dexpressionproject.version -q -DforceStdout
# 修改版本号
mvn -f pom.xml versions:set -DoldVersion* -DnewVersion1.2.0-SNAPSHOT -DprocessAllModulestrue -DallowSnapshotstrue -DgenerateBackupPomstrue
# 修改版本号
mvn versions:set -DnewVersion1.2.0-SNAPSHOT
# 回退版本号
mvn versions:revert11.pluginManagement
plugins 和 pluginManagement 的区别和我们前面研究过的 dependencies 和 dependencyManagement 的区别是非常类似的。plugins 下的 plugin 是真实使用的而 pluginManagement 下的 plugins 下的 plugin 则仅仅是一种声明子项目中可以对 pluginManagement 下的 plugin 进行信息的选择、继承、覆盖等。
buildpluginManagementplugins!-- maven-surefire-plugin 插件用于运行单元测试。 --!-- 注意需要使用 3.0.X因为要支持 Junit 5 版本 --plugingroupIdorg.apache.maven.plugins/groupIdartifactIdmaven-surefire-plugin/artifactIdversion3.0.0-M5/version/plugin!-- maven-compiler-plugin 插件解决 Lombok MapStruct 组合 --plugingroupIdorg.apache.maven.plugins/groupIdartifactIdmaven-compiler-plugin/artifactIdversion3.8.1/versionconfigurationannotationProcessorPathspathgroupIdorg.springframework.boot/groupIdartifactIdspring-boot-configuration-processor/artifactIdversion2.7.18/version/pathpathgroupIdorg.projectlombok/groupIdartifactIdlombok/artifactIdversion1.18.30/version/pathpathgroupIdorg.mapstruct/groupIdartifactIdmapstruct-processor/artifactIdversion1.5.5.Final/version/path/annotationProcessorPaths/configuration/plugin/plugins/pluginManagement
/build