3.1 整合策略

  1. SSM = Spring + SpringMVC + Mybatis
  2. 先整合Spring+Mybatis,然后再整合SpringMVC

    3.2 Mybatis整合Spring

    3.2.1 pom文件

    1. <!--junit-->
    2. <dependency>
    3. <groupId>junit</groupId>
    4. <artifactId>junit</artifactId>
    5. <version>4.12</version>
    6. <scope>test</scope>
    7. </dependency>
    8. <!--mybatis-->
    9. <dependency>
    10. <groupId>org.mybatis</groupId>
    11. <artifactId>mybatis</artifactId>
    12. <version>3.4.5</version>
    13. </dependency>
    14. <!--spring相关-->
    15. <dependency>
    16. <groupId>org.springframework</groupId>
    17. <artifactId>spring-context</artifactId>
    18. <version>5.1.12.RELEASE</version>
    19. </dependency>
    20. <dependency>
    21. <groupId>org.springframework</groupId>
    22. <artifactId>spring-test</artifactId>
    23. <version>5.1.12.RELEASE</version>
    24. </dependency>
    25. <dependency>
    26. <groupId>org.springframework</groupId>
    27. <artifactId>spring-jdbc</artifactId>
    28. <version>5.1.12.RELEASE</version>
    29. </dependency>
    30. <dependency>
    31. <groupId>org.springframework</groupId>
    32. <artifactId>spring-tx</artifactId>
    33. <version>5.1.12.RELEASE</version>
    34. </dependency>
    35. <dependency>
    36. <groupId>org.springframework</groupId>
    37. <artifactId>spring-aop</artifactId>
    38. <version>5.1.12.RELEASE</version>
    39. </dependency>
    40. <dependency>
    41. <groupId>org.aspectj</groupId>
    42. <artifactId>aspectjweaver</artifactId>
    43. <version>1.8.9</version>
    44. </dependency>
    45. <!--mybatis与spring的整合包-->
    46. <dependency>
    47. <groupId>org.mybatis</groupId>
    48. <artifactId>mybatis-spring</artifactId>
    49. <version>2.0.3</version>
    50. </dependency>
    51. <!--数据库驱动jar-->
    52. <dependency>
    53. <groupId>mysql</groupId>
    54. <artifactId>mysql-connector-java</artifactId>
    55. <version>5.1.46</version>
    56. </dependency>
    57. <!--druid连接池-->
    58. <dependency>
    59. <groupId>com.alibaba</groupId>
    60. <artifactId>druid</artifactId>
    61. <version>1.1.21</version>
    62. </dependency>
    s