Maven 基础环境搭建 项目依赖jar包导入

一、创建一个Maven工程

  不清楚的话请查阅其它文档。

二、引入项目依赖的jar包

  1、Spring

  2、SpringMvc

  3、Mybatis

  4、 数据库连接池,驱动

  5、其它(jstl、servlet-api、junit)

三、方法

  Maven工程jar包库:http://mvnrepository.com/

  1、搜索框里输入自己想要的jar包名称;

     2、Mybatis为例,选择对应的版本;

  3、复制如下图所示的配置代码;

  4、粘贴到自己Maven工程文件下的pom.xml中(后面会附完整示例配置);

  附:完整pom.xml配置信息。

 1 <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">
 2   <modelVersion>4.0.0</modelVersion>
 3   <groupId>com.hugo</groupId>
 4   <artifactId>ssm-curd</artifactId>
 5   <version>0.0.1-SNAPSHOT</version>
 6   <packaging>war</packaging>
 7   
 8   <!-- 引入项目依赖的jar包 -->
 9   <!--SpringMVC、Spring-->
10   <!-- https://mvnrepository.com/artifact/org.springframework/spring-webmvc -->
11   <dependencies>
12       <!-- https://mvnrepository.com/artifact/org.springframework/spring-webmvc -->
13     <dependency>
14         <groupId>org.springframework</groupId>
15         <artifactId>spring-webmvc</artifactId>
16         <version>5.0.0.RELEASE</version>
17     </dependency>
18 
19     <!-- Spring-Jdbc  -->
20     <!-- https://mvnrepository.com/artifact/org.springframework/spring-jdbc -->
21     <dependency>
22         <groupId>org.springframework</groupId>
23         <artifactId>spring-jdbc</artifactId>
24         <version>5.0.0.RELEASE</version>
25     </dependency>
26     <!-- Spring aspect 面向切面编程 -->
27     <!-- https://mvnrepository.com/artifact/org.springframework/spring-aspects -->
28     <dependency>
29         <groupId>org.springframework</groupId>
30         <artifactId>spring-aspects</artifactId>
31         <version>5.0.0.RELEASE</version>
32     </dependency>
33     <!-- Mybatis -->
34     <!-- https://mvnrepository.com/artifact/org.mybatis/mybatis -->
35     <dependency>
36         <groupId>org.mybatis</groupId>
37         <artifactId>mybatis</artifactId>
38         <version>3.4.5</version>
39     </dependency>
40     <!-- Mybatis Spring整合的适配包 -->
41     <!-- https://mvnrepository.com/artifact/org.mybatis/mybatis-spring -->
42     <dependency>
43         <groupId>org.mybatis</groupId>
44         <artifactId>mybatis-spring</artifactId>
45         <version>1.3.0</version>
46     </dependency>
47     <!-- c3p0 数据库连接池 -->
48     <!-- https://mvnrepository.com/artifact/com.mchange/c3p0 -->
49     <dependency>
50         <groupId>com.mchange</groupId>
51         <artifactId>c3p0</artifactId>
52         <version>0.9.5.2</version>
53     </dependency>
54     <!--  mysql数据库驱动 -->
55     <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
56     <dependency>
57         <groupId>mysql</groupId>
58         <artifactId>mysql-connector-java</artifactId>
59         <version>6.0.6</version>
60     </dependency>
61     
62   </dependencies>
63   
64 </project>
原文地址:https://www.cnblogs.com/hugo01/p/8031591.html