发布时间:2022-08-19 12:55
把Maven配置到Eclipse
1、修改本地仓库路径:打开Maven目录D:\Java\apache-maven-3.3.9\conf,修改settings.xml文件
<localRepository>D:\Java\repositorylocalRepository>
2、配置Maven程序:打开Eclipse-->Window-->Preferences-->Maven-->Installations
3、配置User Settings,让eclipse知道Maven仓库位置
4、构建索引:打开Eclipse-->Window-->Show View-->Other-->Maven Repositories,右键Local Repositoy(注意后面仓库路径是否正确,如不正确请刷新),点击Rebuild Index
Eclipse新建Maven项目
1、新建Maven Project
2、跳过原型选择,创建相对完整目录结构的Maven项目
3、填写项目信息
4、创建好的web项目会报错,在src/main/webapp新建WEB-INF,创建web.xml
5、原来jdk编译版本1.5,在pom.xml中添加插件,修改jdk版本信息,并刷新Maven项目
-
-
<build>
-
<plugins>
-
<plugin>
-
<groupId>org.apache.maven.plugin
groupId>
-
<artifactId>maven-compiler-plugin
artifactId>
-
<version>3.5.1
version>
-
<configuration>
-
<source>1.7
source>
-
<target>1.7
target>
-
<encoding>UTF-8
encoding>
-
configuration>
-
plugin>
-
plugins>
-
build>
6、查找依赖
依赖范围
Maven项目标准目录结构
坐标定义
pom基本设置
-
-
<modelVersion>4.0.0
modelVersion>
-
-
<groupId>cn.feicui
groupId>
-
-
<artifactId>BOS_1
artifactId>
-
-
-
<version>0.0.1-SNAPSHOT
version>
-
-
<packaging>war
packaging>
-
-
<name>
name>
-
-
<url>
url>
-
-
<description>
description>
-
<developers>
developers>
-
<licenses>
licenses>
-
<organization>
organization>
-
-
-
<dependencies>
-
<dependency>
-
<groupId>
groupId>
-
<artifactId>
artifactId>
-
<version>
version>
-
<type>
type>
-
-
-
-
-
-
-
-
<scope>test
scope>
-
-
<optional>
optional>
-
-
<exclusions>
-
<exclusion>
exclusion>
-
exclusions>
-
dependency>
-
dependencies>
-
-
-
<dependencyManagement>
-
<dependencies>
-
<dependency>
dependency>
-
dependencies>
-
dependencyManagement>
-
-
<build>
-
-
<plugins>
-
<plugin>
-
<groupId>
groupId>
-
<artifactId>
artifactId>
-
<version>
version>
-
plugin>
-
plugins>
-
build>