Maven的安装与配置及在Eclipe中整合Maven

一、Maven的安装与配置

1、Maven下载和安装

下载maven(maven官网下载)并解压缩

2、Maven的环境配置

2.1 JAVA_HOME配置正确

2.2 MAVEN_HOME配置

在这里插入图片描述

2.3 PATH设置

在这里插入图片描述

2.4 mvn -v 查看是否安装配置成功

在这里插入图片描述

3、Maven相关Setting

3.1 自定义仓库存储位置

 <localRepository>D:\Path\apache-maven-3.5.4\repository</localRepository>

3.2 修改mirror

   <mirror>
      <id>alimaven</id>
      <mirrorOf>central</mirrorOf>
      <name>aliyun maven</name>
      <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
    </mirror>

3.3 设置jdk版本

<profile>
	  <id>jdk-1.8</id>
	  <activation>
		<activeByDefault>true</activeByDefault>
		<jdk>1.8</jdk>
	  </activation>
	  <properties>
		<maven.compiler.source>1.8</maven.compiler.source>
		<maven.compiler.target>1.8</maven.compiler.target>
		<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
	  </properties>
</profile>

二、Eclipse整合Maven

1、查看本版本Eclipse中是否已经集成Maven插件

在这里插入图片描述
在这里插入图片描述
若如上操作查看存在Maven选项,则是已经集成了Maven,否则需要安装插件或重新下载安装已经集成了Maven的Eclipes

2、Maven插件的配置

2.1 添加本地安装的Maven

在这里插入图片描述
在这里插入图片描述

2.2 导入Setting

在这里插入图片描述

三、Eclipse创建Maven项目

1、创建maven项目

在这里插入图片描述
在这里插入图片描述

2、pom.xml文件说明

<!-- project,项目的根标签 -->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
    <!-- 工程组标识,通常是公司的域名反写 -->
  <groupId>com.zhou.maven</groupId>
    <!-- 项目名 -->
  <artifactId>TestApp</artifactId>
    <!-- 项目版本 -->
  <version>0.0.1-SNAPSHOT</version>
  	<!-- 打包类型,war/jar包 -->
  <packaging>war</packaging>
  
  <properties>
   	<!-- spring版本号 -->
	<spring.version>4.3.3.RELEASE</spring.version>
	<!-- log4j日志文件管理包版本 -->
	<slf4j.version>1.7.7</slf4j.version>
	<log4j.version>1.2.17</log4j.version>
  	<hibernate.version>4.3.8.Final</hibernate.version>
  	<mysql.version>5.1.42</mysql.version>
  </properties>
    
    
  	<!-- jar依赖dependencies -->
  <dependencies>
  	<!-- hibernate -->
  	<dependency>
	    <groupId>org.hibernate</groupId>
	    <artifactId>hibernate-core</artifactId>
	    <version>${hibernate.version}</version>
	</dependency>
	
	    <!-- Servlet的依赖 -->
	<dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>3.1.0</version>
        <scope>provided</scope>
    </dependency>
    
     <!-- jsp的依赖 -->
    <dependency>
	<groupId>javax.servlet.jsp</groupId>
	    <artifactId>javax.servlet.jsp-api</artifactId>
	    <version>2.2.1</version>
	    <scope>provided</scope>
	</dependency>

    <!-- spring-core的依赖 -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <vrsion>4.2.5.RELEASE</version>
        <scope>compile</scope>
    </dependency>
    
	<!-- dependencies... -->

  </dependencies>

	<!-- maven打包插件 -->
	<build>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
				<configuration>
					<source>1.8</source>
					<target>1.8</target>
				</configuration>
				<executions>
					<execution>
						<goals>
							<goal>repackage</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>
  
</project>

3、Maven项目的包结构

3.1 一般web项目

需要手动设置生成webapp及web.xml
在项目上右键——properties
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

3.2 spring boot项目包结构

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值