maven,算不算是一个框架?

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了maven,算不算是一个框架?相关的知识,希望对你有一定的参考价值。

不算!不是开发框架。

Maven 是一个项目管理和整合工具。Maven 为开发者提供了一套完整的构建生命周期框架。开发团队几乎不用花多少时间就能够自动完成工程的基础构建配置,因为 Maven 使用了一个标准的目录结构和一个默认的构建生命周期。

最主要优势可以总结一下三点:

    生命周期管理,便捷的构建过程;

    依赖管理,方便引入所需依赖 Jar 包;

    仓库管理,提供统一管理所有 Jar 包的工具;

    目录结构管理,提供了一套标准的目录结构(基本上所有的web项目,目录结构几乎都是相同的)

参考技术A 它是一个用来管理项目的jar的工具,项目针对需要的jar包,只需要配置pom.xml文件即可以了,相关的jar包参数的配置也可以在maven官网上可以找见的。以上是我使用maven的理解。 参考技术B 不算
这只是一个jar包引入的管理仓库
你需要在配置文件汇总定义好本项目需要使用到的jar包
以及版本信息
其他的交给其后台去下载相关文件
有帮助别忘记采纳亲!

maven项目配置框架

任何一个maven项目都会继承一个默认的父pom配置:Super POM,详见:https://maven.apache.org/guides/introduction/introduction-to-the-pom.html 。
在pom.xml中可以直接使用一些变量值,如:

${project.groupId}               The group id of current project
${project.version}          The version of current project
${project.build.sourceDirectory} The source directory of current project
${project.basedir}               The directory that the current project resides in.
${project.baseUri}               The directory that the current project resides in, represented as an URI. Since Maven 2.1.0
${maven.build.timestamp}         The timestamp that denotes the start of the build. Since Maven 2.1.0-M1

详见:https://maven.apache.org/guides/introduction/introduction-to-the-pom.htmlAvailable Variables

 

一个实际完整的生产项目maven配置框架示例:

技术分享
 1 <?xml version="1.0"?>
 2 <project
 3     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
 4     xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 5     <modelVersion>4.0.0</modelVersion>
 6     
 7     <artifactId>xxx-xxx</artifactId>
 8     <version>x.x.x</version>
 9     <packaging>war</packaging>
10     <name>xxx</name>
11     <url>xxx</url>
12     
13     <!-- 父模块,可选. -->
14     <parent>
15         <groupId>xxx</groupId>
16         <artifactId>xxx</artifactId>
17         <version>x.x.x</version>
18     </parent>
19 
20     <!-- 定义属性 -->
21     <properties>
22         <!-- 项目编码 -->
23         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
24         <!-- 时间格式 -->
25         <maven.build.timestamp.format>yyyyMMdd</maven.build.timestamp.format>
26     </properties>
27 
28     <!-- 依赖配置 -->
29     <dependencies>
30         ...
31         <dependency>
32             <groupId>xxx</groupId>
33             <artifactId>xxx</artifactId>
34             <version>x.x.x</version>
35         </dependency>
36         ...
37     </dependencies>
38 
39     <!-- 定义profile: 将开发配置和生产配置分离开 -->
40     <profiles>
41         <profile>
42             <id>dev</id>
43             <properties>
44                 <profile.dir>dev</profile.dir>
45             </properties>
46         </profile>
47         <profile>
48             <id>test</id>
49             <properties>
50                 <profile.dir>test</profile.dir>
51             </properties>
52         </profile>
53         <profile>
54             <id>prod</id>
55             <properties>
56                 <profile.dir>prod</profile.dir>
57             </properties>
58         </profile>
59     </profiles>
60 
61     <!-- 打包 -->
62     <build>
63         <finalName>xxx</finalName>
64         
65         <!-- 打包资源 -->
66         <resources>
67             <resource>
68                 <directory>src/main/java</directory>
69                 <excludes>
70                     <exclude>.svn</exclude>
71                     <exclude>.java</exclude>
72                 </excludes>
73             </resource>
74             <resource>
75                 <directory>src/main/resources/profiles/${profile.dir}</directory>
76                 <excludes>
77                     <exclude>.svn</exclude>
78                 </excludes>
79             </resource>
80         </resources>
81         
82         <!-- 配置打包插件,如: 依赖处理,资源复制,压缩打包等 -->
83         <plugins>
84             <plugin>
85                 ...
86             </plugin>
87         </plugins>
88     </build>
89 </project>
View Code

 


以上是关于maven,算不算是一个框架?的主要内容,如果未能解决你的问题,请参考以下文章

eclipse maven Spring

JS datatable表中的某一列如何获取

初识Java中的maven项目管理包

创建一个最简单的SpringBoot应用

我个人的Java学习经验(一家之言)

ssm+maven 框架整合