Maven快速入门

简介: Maven快速入门

1. 下载Maven

官方地址:http://maven.apache.org/download.cgi


image.png


解压并新建一个本地仓库文件夹


image.png



2.配置本地仓库路径


image.png


image.png

C:\apache-maven-3.5.2\conf\settings.xml

line:46

<localRepository>E:\MavenRepository</localRepository>

line:160

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

新建本地仓库目录E:\MavenRepository

3.配置maven环境变量


image.png

image.png


image.png


image.png


4.在IntelliJ IDEA中配置maven

打开-File-Settings


image.png




5.新建maven WEB项目

打开-File-New-Project

点击NEXT


image.png



点击NEXT


image.png


添加的配置为 archetypeCatalog=internal

点击NEXT


image.png


点击NEXT


image.png

点击Finish后项目开始创建

点击右下角查看进去

image.png

6.maven web模板项目结构


image.png

image.png

image.png

7.配置依赖jar包

image.png


jar包配置搜索

官方地址:http://mvnrepository.com/


SSM pom文件配置

<?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">
  <modelVersion>4.0.0</modelVersion>
  <groupId>neusoft</groupId>
  <artifactId>neusoft</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>war</packaging>
  <name>neusoft 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.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
      <!-- spring版本号 -->
      <spring.version>4.0.2.RELEASE</spring.version>
      <!-- mybatis版本号 -->
      <mybatis.version>3.2.6</mybatis.version>
      <!-- log4j日志文件管理包版本 -->
      <slf4j.version>1.7.7</slf4j.version>
      <log4j.version>1.2.17</log4j.version>
  </properties>
  <dependencies>
      <dependency>
          <groupId>junit</groupId>
          <artifactId>junit</artifactId>
          <version>3.8.1</version>
          <scope>test</scope>
      </dependency>
      <!-- 导入java ee jar包(可以去除index.jsp报错) -->
      <dependency>
          <groupId>javax</groupId>
          <artifactId>javaee-api</artifactId>
          <version>7.0</version>
      </dependency>
      <dependency>
          <groupId>junit</groupId>
          <artifactId>junit</artifactId>
          <version>4.11</version>
          <!-- 表示开发的时候引入,发布的时候不会加载此包 -->
          <scope>test</scope>
      </dependency>
      <!-- spring核心包 -->
      <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-core</artifactId>
          <version>${spring.version}</version>
      </dependency>
      <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-web</artifactId>
          <version>${spring.version}</version>
      </dependency>
      <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-oxm</artifactId>
          <version>${spring.version}</version>
      </dependency>
      <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-tx</artifactId>
          <version>${spring.version}</version>
      </dependency>
      <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-jdbc</artifactId>
          <version>${spring.version}</version>
      </dependency>
      <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-webmvc</artifactId>
          <version>${spring.version}</version>
      </dependency>
      <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-aop</artifactId>
          <version>${spring.version}</version>
      </dependency>
      <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-context-support</artifactId>
          <version>${spring.version}</version>
      </dependency>
      <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-test</artifactId>
          <version>${spring.version}</version>
      </dependency>
      <!-- mybatis核心包 -->
      <dependency>
          <groupId>org.mybatis</groupId>
          <artifactId>mybatis</artifactId>
          <version>${mybatis.version}</version>
      </dependency>
      <!-- mybatis/spring包 -->
      <dependency>
          <groupId>org.mybatis</groupId>
          <artifactId>mybatis-spring</artifactId>
          <version>1.2.2</version>
      </dependency>
      <!-- 导入Mysql数据库链接jar包 -->
      <dependency>
          <groupId>mysql</groupId>
          <artifactId>mysql-connector-java</artifactId>
          <version>5.1.30</version>
      </dependency>
      <!-- 导入dbcp的jar包,用来在applicationContext.xml中配置数据库 -->
      <dependency>
          <groupId>commons-dbcp</groupId>
          <artifactId>commons-dbcp</artifactId>
          <version>1.2.2</version>
      </dependency>
      <!-- JSTL标签类 -->
      <dependency>
          <groupId>jstl</groupId>
          <artifactId>jstl</artifactId>
          <version>1.2</version>
      </dependency>
      <!-- 日志文件管理包 -->
      <!-- log start -->
      <dependency>
          <groupId>log4j</groupId>
          <artifactId>log4j</artifactId>
          <version>${log4j.version}</version>
      </dependency>
      <!-- 格式化对象,方便输出日志 -->
      <dependency>
          <groupId>com.alibaba</groupId>
          <artifactId>fastjson</artifactId>
          <version>1.1.41</version>
      </dependency>
      <dependency>
          <groupId>org.slf4j</groupId>
          <artifactId>slf4j-api</artifactId>
          <version>${slf4j.version}</version>
      </dependency>
      <dependency>
          <groupId>org.slf4j</groupId>
          <artifactId>slf4j-log4j12</artifactId>
          <version>${slf4j.version}</version>
      </dependency>
      <!-- log end -->
      <!-- 映入JSON -->
      <dependency>
          <groupId>org.codehaus.jackson</groupId>
          <artifactId>jackson-mapper-asl</artifactId>
          <version>1.9.13</version>
      </dependency>
      <!-- 上传组件包 -->
      <dependency>
          <groupId>commons-fileupload</groupId>
          <artifactId>commons-fileupload</artifactId>
          <version>1.3.1</version>
      </dependency>
      <dependency>
          <groupId>commons-io</groupId>
          <artifactId>commons-io</artifactId>
          <version>2.4</version>
      </dependency>
      <dependency>
          <groupId>commons-codec</groupId>
          <artifactId>commons-codec</artifactId>
          <version>1.9</version>
      </dependency>
      <dependency>
          <groupId>com.alibaba</groupId>
          <artifactId>druid</artifactId>
          <version>1.0.9</version>
      </dependency>
  </dependencies>
  <build>
    <finalName>neusoft</finalName>
      <resources>
          <resource>
              <directory>src/main/java</directory>
              <!-- 此配置不可缺,否则mybatis的Mapper.xml将会丢失 -->
              <includes>
                  <include>**/*.xml</include>
              </includes>
          </resource>
          <!--指定资源的位置-->
          <resource>
              <directory>src/main/resources</directory>
          </resource>
      </resources>
    <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.0.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.7.0</version>
        </plugin>
        <plugin>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>2.20.1</version>
        </plugin>
        <plugin>
          <artifactId>maven-war-plugin</artifactId>
          <version>3.2.0</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>


Intelij安装mybatis代码自动生成器插件


参考

https://www.jianshu.com/p/d019c9880d25

目录
相关文章
|
6月前
|
Java 数据库连接 Apache
JavaWeb基础第二章(Maven项目与MyBatis 的快速入门与配置)
JavaWeb基础第二章(Maven项目与MyBatis 的快速入门与配置)
|
7月前
|
XML Java 大数据
答应粉丝的Maven仓库学习笔记,今天它来了 一起来学习快速入门Maven
答应粉丝的Maven仓库学习笔记,今天它来了 一起来学习快速入门Maven
129 1
|
7月前
|
Java Linux 测试技术
Maven快速入门
Maven快速入门
53 0
|
Java Linux 测试技术
Maven快速入门
Maven快速入门
72 0
|
Java 数据库连接 Maven
MyBatis快速入门——第五章、maven整合Mybatis&Servlet_tomcat(3)
MyBatis快速入门——第五章、maven整合Mybatis&Servlet_tomcat
164 0
MyBatis快速入门——第五章、maven整合Mybatis&Servlet_tomcat(3)
|
SQL Java 数据库连接
MyBatis快速入门——第五章、maven整合Mybatis&Servlet_tomcat(2)
MyBatis快速入门——第五章、maven整合Mybatis&Servlet_tomcat
115 0
MyBatis快速入门——第五章、maven整合Mybatis&Servlet_tomcat(2)
|
Java 关系型数据库 MySQL
MyBatis快速入门——第五章、maven整合Mybatis&Servlet_tomcat(1)
MyBatis快速入门——第五章、maven整合Mybatis&Servlet_tomcat
120 0
MyBatis快速入门——第五章、maven整合Mybatis&Servlet_tomcat(1)
|
Java 关系型数据库 MySQL
MyBatis快速入门——第一章、idea的maven配置与demo实例
MyBatis快速入门——第一章、idea的maven配置与demo实例
179 0
MyBatis快速入门——第一章、idea的maven配置与demo实例
|
XML IDE Java
Maven快速入门
本文可以帮助不熟悉Maven的开发者快速掌握Maven的基本操作
281 0
|
存储 缓存 算法
Gradle快速入门使用指南 - Maven转移到Gradle
Gradle快速入门使用指南 - Maven转移到Gradle
1186 0
Gradle快速入门使用指南 - Maven转移到Gradle