Spring学习心得-初识Maven

Spring学习心得-初始Maven

什么是Maven

Maven项目对象模型(POM),可以通过一小段描述信息来管理项目的构建,报告和文档的项目管理工具软件。

Maven的创建(IDE用Idea为例)

File->New->project->maven
Spring学习心得-初识Maven
点击Next进入下一个界面
Spring学习心得-初识MavenSpring学习心得-初识MavenSpring学习心得-初识Maven
创建好之后的工程目录
Spring学习心得-初识Maven
Main目录(主目录)

main目录 简单介绍
java 存放java代码文件
resources 一般存放的是应用上下文环境的配置文件

Test目录(测试目录)

test目录 简单介绍
java 存放java的测试文件

pom.xml的使用
一般pom.xml中配置的是种中央仓库的Jar包,我们要从中央仓库把我们的需要的Jar下载到本地
(maven中央仓库的地址:https://mvnrepository.com

例如我们要从中央仓库把spring的核心文件下载下来 (就可以在原来pom.xml的后面加入):

<dependencies>
        <!-- https://mvnrepository.com/artifact/org.springframework/spring-context -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>5.1.5.RELEASE</version>
        </dependency>
        
 		<!-- 更多的依赖 -->
 		<dependency>
 			...
		</dependency>
	
<dependencies>