参考: https://www.runoob.com/maven/maven-pom.html
参考: https://blog.csdn.net/athanasy1/article/details/100620517
1: 版本号 <version>0.0.1-SNAPSHOT</version>
maven版本类型通常分为: snapshots Release
一般来说snapshots版本代表正在开发中的版本,
release代表比较稳定的发布版本.
<groupId>com.demo</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>demo</name>
maven会根据pom中version是否带-SNAPSHOT进行判断当前版本是否为快照版本
如果不带 -SNAPSHOT则默认为时release版本(注意: 一定是 -SNAPSHOT )
为了方便切换 snapshots 和 release 通常我们在pom文件中这样配置
<distributionManagement>
<snapshotRepository>
<id>local_maven-snapshots</id>
<name>local_maven-snapshots</name>
<url>http://localhost:8081/repository/maven-snapshots/</url>
<layout>default</layout>
</snapshotRepository>
<repository>
<id>local-maven-release</id>
<name>localhost maven</name>
<url>http://localhost:8081/repository/maven-release/</url>
</repository>
</distributionManagement>
maven 会自动根据版本后缀上传到对应的仓库中
2: 依赖 <dependencyManagement>
排除依赖:使用exclusions标签排除jar
<dependencies>
<dependency>
<groupId>net.mingsoft</groupId>
<artifactId>shiro-freemarker-tags</artifactId>
<version>0.1</version>
<!-- 排除掉里面的quartz包 -->
<exclusions>
<exclusion>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
3: 报表 <reporting>
该元素描述使用报表插件产生报表的规范。当用户执行"mvn site",这些报表就会运行。 在页面导航栏能看到所有报表的链接。
4: <repositories>和 <pluginRepositories>
注意事项: https://www.cnblogs.com/default/p/11856188.html
指定的是maven的依赖远程仓库和插件远程仓库
插件和依赖区别 转至这里: https://www.cnblogs.com/gaoquanquan/p/10726257.html
依赖:运行时开发时都需要用到的jar包,比如项目中需要一个Json的jar包,就要添加一个依赖,这个依赖在项目运行时也需要,因此在项目打包时需要把这些依赖也打包进项目里;
插件:在项目开的发时需要,但是在项目运行时不需要,因此在项目开发完成后不需要把插件打包进项目中,比如有个可以自动生成getter和setter的插件,这就是插件了,因为这玩意在编译时生成getter和setter,编译结束后就没用了,所以项目打包时并不需要把插件放进去
5: <developers>
开发者 没啥用
6: <distributionManagement>
上传到指定仓库 / setting.xml文件中要配置对应<id>的账号和密码
(对应version标签中的案例)
<distributionManagement>
<repository>
<id>maven-releases</id>
<url>http://xxxxx/nexus/repository/maven-releases/</url>
</repository>
<snapshotRepository>
<id>maven-snapshots</id>
<url>http://xxxx/nexus/repository/maven-snapshots/</url>
</snapshotRepository>
</distributionManagement>
7: 构建 <build>
build标签参考: https://www.jb51.net/article/87108.htm
参考:https://blog.csdn.net/taiyangdao/article/details/52374125
pom.xml 文件中有两种build标签,一种在</project>标签下
一种在<profiles>标签下 详解参考: https://blog.csdn.net/java_collect/article/details/83870215
</project>标签下build参考: https://www.runoob.com/maven/maven-pom.html
springboot 打包成一个可执行jar包
<build>标签是这样的
<build>
<!-- 生成一个可执行jar包-->
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!-- 跳过单元测试-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
<!-- 配置生成源码包-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<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>
</plugins>
</build>
执行: java -jar xxx.jar
springboot 生成普通包(只包含编译后的class文件,不包含依赖的lib文件)
参考: https://blog.csdn.net/u013177446/article/details/54134394
1:注释掉生成可执行包的标签
2: 在<build>同级标签中添加
jar
<packaging>jar</packaging>
<!-- <build>-->
<!-- <plugins>-->
<!-- <plugin>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-maven-plugin</artifactId>-->
<!-- </plugin>-->
<!-- </plugins>-->
<!-- </build>-->