Mvaen
content:
- Introduction to maven
- maven function
- maven create
- maven package directory structure
- How maven creates a web project
- How to import xml project management in maven
- maven life cycle
One, maven overview
- Apache Maven is a software project management and comprehensive tool, based on object model (POM) , Maven can manage project construction, reports and files from a central piece of information.
- maven : Essentially a management project software maven is produced by Apche and also written in java.
Second, the role of maven
- project life cycle: compile, test, package, deploy and run.
- management (jar package): maven can help us manage the jar packages needed for development.
- management plug-in: maven can help us manage the plug-ins that we need in a unified way.
Maven creation
1. The first step: Click File in the upper right corner and then new Porject
Then choose maven next
2. The second step:
Groupld: package structure (directory)
Artifactld: project name
Version: version number
Package directory structure
Maven configuration introduction
mian -> 主工程的代码
java目录 -> 写java代码
test -> 测试代码
resources -> 存放配置文件的目录
pom.xml -> 当前maven工程的配置文件{
a.jar包依赖
b.插件管理
}
How to create a web project
How to configure webapp directory and web.xml
Step 1: Click File --> Project Structure...
Click on Facets to copy this path (look at your own)
Step 2: Copy and paste here
third step
Click Apply How to click OK
How to import xml project management in maven
If you find pom.xml after the previous configuration is complete
<!-- 项目发出,都要先打包(类似于压缩)
打包方式:
java项目 —> jar包 ( java archives )
web项目 —> war包 ( java archives)
pom文件 —>
默认 jar
-->
<groupId>com.kjzz</groupId> <!-- 域名 -->
<artifactId>maven_text03</artifactId> <!-- 项目名 -->
<version>1.0-SNAPSHOT</version> <!-- 版本号 -->
<packaging>war</packaging> <!-- 打包方式 -->
<dependencies>
<!-- 测试 -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<!-- mysql连接工具 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.32</version>
</dependency>
<!-- servlet -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency>
<!-- jsp页面 -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jsp-api</artifactId>
<version>2.0</version>
</dependency>
</dependencies>
<!--设置插件-->
<build>
<plugins>
<!--JDK编译插件-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<!-- tomcat7插件 -->
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<!--
解决get请求乱码
-->
<uriEncoding>utf-8</uriEncoding>
<port>8080</port>
<path>/</path>
</configuration>
</plugin>
</plugins>
</build>
maven life (project) cycle
Maven function: create a project
三套声明周期
1. clean : 清理之前构造生产的文件(重要)
mvn clean 清除编译生成的文件(target目录)
2. default : 核心 {
1.default 创建
2.compile 编译
3.text 测试
运行所有测试(text)代码
4.package 打包
java项目: jar (成功了)
web项目: war
5.install 安装
安装本地maven仓库(坐标)
}
注意事项:
1. 直接执行后续步骤,前置步骤自动执行
2. 前置步骤失败,后续步骤不再执
3. site : 产生报告,发布站点 (展示用不到)
Note: maven and idea are not the same manufacturer, so there is no need to be compatible with idea
Added idea function: click file
show is Explorer is the current directory of the opened file
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。