maven的基本使用

  1. 去官网下载安装
    image
  2. 配置环境变量
    image
    image
  3. 设置本地仓库存放的路径
    image
  4. 设置阿里镜像源
    image
  5. idea中maven的基本使用
    5.1 image
    5.2 image
    5.3 image
    5.4 image
    5.5 image
    5.6 image
    5.7 项目创建成功后,记得看一下设置中idea中maven的设置,因为有的项目idea会默认使用自带的maven
    image
    5.8 image
    5.9 不使用maven的模板创建maven项目
    image
    5.10
    image
    5.11 在之前用模板创建的maven的javaweb项目中补全文件夹
    image
  6. 配置tomcat
    6.1 image
    6.2 image
    6.3 image
    6.4 选择第一个即可image
    6.5 image
    6.6
    image
  7. idea中maven窗口
    image
  8. pom核心文件
<?xml version="1.0" encoding="UTF-8"?>
<!-- maven版本和头文件 -->
<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>
<!--这里就是我们配置的gav -->
  <groupId>com.daweiguo</groupId>
  <artifactId>maven_use</artifactId>
  <version>1.0-SNAPSHOT</version>
<!--  打包方式-->
<!--  jar是java应用-->
<!--  war是javaweb应用-->
  <packaging>war</packaging>

  <name>maven_use Maven Webapp</name>
  <!-- FIXME change it to the project's website -->
  <url>http://www.example.com</url>
<!--配置-->
  <properties>
<!-- 项目的默认构建编码   -->
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!--    编码版本 -->
    <maven.compiler.source>1.7</maven.compiler.source>
    <maven.compiler.target>1.7</maven.compiler.target>
  </properties>
<!-- 项目依赖-->
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.11</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

<!--  项目构建用的东西-->
  <build>
<!--    在build中配置resources,来配置我们资源导出失败的问题-->
    <resources>
      <resource>
        <directory>src/main/resources</directory>
        <excludes>
          <exclude>**/*.properties</exclude>
          <exclude>**/*.xml</exclude>
        </excludes>
        <filtering>false</filtering>
      </resource>
      <resource>
        <directory>src/main/java</directory>
        <includes>
          <include>**/*.properties</include>
          <include>**/*.xml</include>
        </includes>
        <filtering>false</filtering>
      </resource>
    </resources>

    <finalName>maven_use</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>

posted @ 2021-09-20 13:12  DaWeiGuo  阅读(95)  评论(0编辑  收藏  举报