Eclipse新建Maven项目
warning:
这篇文章距离上次修改已过1845天,其中的内容可能已经有所变动。
在Eclipse新建Maven项目
初始化项目
打开文件(file)>新建(new)>其他(other)>搜索maven>选择maven project
下一步,勾选创建一个简单项目(跳过原型选择)
下一步,填写Group id
和Artifact id
, Version
默认,Packaging
默认为jar,Name,Description
选填,其他的可以不填
生成的项目结构如下
通过pom.xml文件添加jar包
打开pom.xml文件
搜索需要的jar包
以官方搜索为例,搜索阿里的fastjson
根据提示添加到pom.xml文件里
<dependencies>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.62</version>
</dependency>
</dependencies>
更新jar包
项目上右击>选择maven>update Project
选择需要更新的项目
PS:如果pom.xml报错,请尝试勾选Force Update of Snapshots/Releases
,强制更新下试试