Idea中使用maven创建项目之导入spring和mybatis整合的jar包

1.创建maven项目:
Idea中使用maven创建项目之导入spring和mybatis整合的jar包
点击next,然后
Idea中使用maven创建项目之导入spring和mybatis整合的jar包

这里的GroupId和ArtifactId被统称为“坐标”是为了保证项目唯一性而提出的,如果你要把你项目弄到maven本地仓库去,你想要找到你的项目就必须根据这两个id去查找。

GroupId一般分为多个段,这里我只说两段,第一段为域,第二段为公司名称。域又分为org、com、cn等等许多,其中org为非营利组织,com为商业组织。举个apache公司的tomcat项目例子:这个项目的GroupId是org.apache,它的域是org(因为tomcat是非营利项目),公司名称是apache,ArtifactId是tomcat。
  
  比如我创建一个项目,我一般会将GroupId设置为cn.mht,cn表示域为中国,zr是我个人姓名缩写,ArtifactId设置为testProj,表示你这个项目的名称是testProj,依照这个设置,在你创建Maven工程后,新建包的时候,包结构最好是cn.zr.testProj打头的,如果有个StudentDao[Dao层的],它的全路径就是cn.zr.testProj.dao.StudentDao。
 最后
 Idea中使用maven创建项目之导入spring和mybatis整合的jar包 写上项目名字点击finish
 2。导入spring和mybatis整合的jar包。



org.springframework
spring-core
4.3.18.RELEASE


org.springframework
spring-context
4.3.18.RELEASE


org.springframework
spring-jdbc
4.3.18.RELEASE


org.springframework
spring-tx
4.3.18.RELEASE

    <!--db-->
    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-dbcp2</artifactId>
        <version>2.1.1</version>
    </dependency>
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.1.40</version>
    </dependency>
    <!--mybatis-->
    <dependency>
        <groupId>org.mybatis</groupId>
        <artifactId>mybatis</artifactId>
        <version>3.4.4</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.mybatis/mybatis-spring -->
    <dependency>
        <groupId>org.mybatis</groupId>
        <artifactId>mybatis-spring</artifactId>
        <version>1.3.1</version>
    </dependency>
<!-- log4j -->
    <!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core -->
    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-core</artifactId>
        <version>2.8.2</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.aspectj/aspectjweaver -->
    <dependency>
        <groupId>org.aspectj</groupId>
        <artifactId>aspectjweaver</artifactId>
        <version>1.8.13</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/aopalliance/aopalliance -->
    <dependency>
        <groupId>aopalliance</groupId>
        <artifactId>aopalliance</artifactId>
        <version>1.0</version>
    </dependency>

</dependencies>

好了,一个maven项目就创建好了,可以开始spring和mybatis的整合了。
所有的jar包可以访问官网:https://mvnrepository.com/