当前位置:   article > 正文

千锋逆战1903班Days11上课代码以及笔记_千峰云计算逆战磊哥课堂笔记下载

千峰云计算逆战磊哥课堂笔记下载

在千锋“逆战”学习第 11天,
今天学习了maven的环境配置以及常用命令
每个人生阶段都需要努力去扮好自己的角色,越努力越轻松,越坚强越幸运!
加油!
以下是我的学习内容分享

1、下载
在这里插入图片描述
对压缩包解压得到maven目录
bin
在这里插入图片描述
主要是运行mvn的脚本命令

boot
在这里插入图片描述
plexus-classworlds是一个类加载器框架,Maven使用该框架加载自己的类库。

conf
在这里插入图片描述
全局的配置文件,一般在c盘的user/.m2目录下会生成相同的一个setting.xml文件,如果在ide中不配置该文件的路径,默认会使用在c盘的用户目录下的setting.xml文件

lib
在这里插入图片描述
该目录包含路maven启动需要的java类库,需要注意的是maven-model-builder-3.6.1.jar中包含了pom.xml文件
在这里插入图片描述
pom.xml中配置有
  1.项目构建的默认目录
  2.自带的profile
3.添加的jar类库
LICENSE
记录maven使用的软件许可证
NOTICE
记录maven包含的第三方软件
README.txt
maven的一些描述信息,可以打开了解maven

2、配置环境变量
鼠标右击“此电脑”->“属性”->“高级系统设置”->“环境变量”
在这里插入图片描述
最后将变量配置在path中
在这里插入图片描述
至此,环境变量已配置完成,在win开始菜单打开“cmd”输入mvn -version查看maven版本信息
在这里插入图片描述
3、修改配置文件
打开安装目录下conf文件夹中的setting.xml文件
在这里插入图片描述
①修改本地仓库的地址
在这里插入图片描述
②修改镜像 在标签对中添加阿里镜像(国内推荐)这样有利于j加快ar库的下载速度

<!--阿里云镜像-->
    <mirror>
        <id>alimaven</id>
        <name>aliyun maven</name>   
        <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
        <mirrorOf>central</mirrorOf>        
    </mirror>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

在这里插入图片描述
③修改jdk版本

<profile>
	<id>jdk18</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>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

在这里插入图片描述
4、idea下配置maven
file->seting
在这里插入图片描述
5、maven常用命令
创建maven项目:mvn archetype:create
指定 group: -DgroupId=packageName
指定 artifact:-DartifactId=projectName
创建web项目:-DarchetypeArtifactId=maven-archetype-webapp
创建maven项目:mvn archetype:generate
maven 打包:mvn package
只打jar包:mvn jar:jar
生成源码jar包:mvn source:jar
编译源代码: mvn compile
编译测试代码:mvn test-compile
运行测试:mvn test
清理maven项目:mvn clean
启动tomcat:mvn tomcat:run
启动web应用:mvn tomcat:start
安装本地jar到本地仓库:mvn install:install-file -DgroupId=packageName -DartifactId=projectName -Dversion=version -Dpackaging=jar -Dfile=path

6、idea创建maven项目(第一次需要下载比较慢,需要从中央仓库下载组件)
在这里插入图片描述
①目录结构
java项目
在这里插入图片描述
javaweb项目
在这里插入图片描述
需要自己手动创建缺少的文件夹 file->Project Structure
在这里插入图片描述
在这里插入图片描述

7、pom.xml常用标签介绍


<?xml version="1.0" encoding="UTF-8"?>
<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">
 <!-- 当前pom的版本-->
 <modelVersion>4.0.0</modelVersion>
 <!--坐标-->
 <groupId>org.example</groupId>
 <artifactId>myweb</artifactId>
 <version>1.0-SNAPSHOT</version>
 <!-- 默认是war,其他jar pom等 -->
 <packaging>war</packaging>
 <!--项目描述名 -->
 <name>myweb Maven Webapp</name>
 <!-- 项目地址 -->
 <url>http://www.example.com</url>
 <!-- 配置参数 -->
 <properties>
   <!-- 这里配置项目编译编码为UTF-8-->
   <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
   <maven.compiler.source>1.8</maven.compiler.source>
   <maven.compiler.target>1.8</maven.compiler.target>
 </properties>
 <!-- 依赖集,用于配置依赖 -->
 <dependencies>
   <dependency>
     <!--jar地址-->
     <groupId>junit</groupId>
     <artifactId>junit</artifactId>
     <!--版本号-->
     <version>4.11</version>
     <!-- 依赖范围
      -compile 默认,编译测试运行均有效,会传递
      -provided 在编译和测试时有效,如servletAPI可以加入,不传递
      -runtime 在测试和运行时有效,如JDBCAPI可以加入
      -test 在测试时有效,如junit可以加入
      -system 在编译和测试时有效,与本机系统相关联,移植性差,在系统中以外部jar包的形式引入,不会在仓库中查找
      -import 导入,只能用在dependecyManagement中,表示从其他pom中导入dependecy的配置-->
     <scope>test</scope>
   </dependency>
 </dependencies>

 <build>
   <finalName>myweb</finalName>
   <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
     <plugins>
       <plugin>
         <artifactId>maven-clean-plugin</artifactId>
         <version>3.1.0</version>
       </plugin>
       <!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_war_packaging -->
       <plugin>
         <artifactId>maven-resources-plugin</artifactId>
         <version>3.0.2</version>
       </plugin>
       <plugin>
         <artifactId>maven-compiler-plugin</artifactId>
         <version>3.8.0</version>
       </plugin>
       <plugin>
         <artifactId>maven-surefire-plugin</artifactId>
         <version>2.22.1</version>
       </plugin>
       <plugin>
         <artifactId>maven-war-plugin</artifactId>
         <version>3.2.2</version>
       </plugin>
       <plugin>
         <artifactId>maven-install-plugin</artifactId>
         <version>2.5.2</version>
       </plugin>
       <plugin>
         <artifactId>maven-deploy-plugin</artifactId>
         <version>2.8.2</version>
       </plugin>
     </plugins>
   </pluginManagement>
 </build>
</project>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/weixin_40725706/article/detail/469464
推荐阅读
相关标签
  

闽ICP备14008679号