• Spring Boot事务支持


    一、创建项目

    二、添加依赖

    1. <dependencies>
    2. <dependency>
    3. <groupId>org.projectlombok</groupId>
    4. <artifactId>lombok</artifactId>
    5. </dependency>
    6. <!--mybatis与spring boot整合依赖-->
    7. <dependency>
    8. <groupId>org.mybatis.spring.boot</groupId>
    9. <artifactId>mybatis-spring-boot-starter</artifactId>
    10. <version>1.3.2</version>
    11. </dependency>
    12. <!--mysql驱动-->
    13. <dependency>
    14. <groupId>mysql</groupId>
    15. <artifactId>mysql-connector-java</artifactId>
    16. <version>5.1.47</version>
    17. </dependency>
    18. <!-- druid驱动 -->
    19. <dependency>
    20. <groupId>com.alibaba</groupId>
    21. <artifactId>druid</artifactId>
    22. <version>1.1.12</version>
    23. </dependency>
    24. <!--tomcat内置的JSP解析器-->
    25. <dependency>
    26. <groupId>org.apache.tomcat.embed</groupId>
    27. <artifactId>tomcat-embed-jasper</artifactId>
    28. </dependency>
    29. <dependency>
    30. <groupId>org.springframework.boot</groupId>
    31. <artifactId>spring-boot-starter-web</artifactId>
    32. </dependency>
    33. <dependency>
    34. <groupId>org.springframework.boot</groupId>
    35. <artifactId>spring-boot-starter-test</artifactId>
    36. <scope>test</scope>
    37. </dependency>
    38. </dependencies>
    39. <build>
    40. <resources>
    41. <!--注册dao包下mybatis映射文件为资源目录-->
    42. <resource>
    43. <directory>src/main/java</directory>
    44. <includes>
    45. <include>**/*.xml</include>
    46. </includes>
    47. </resource>
    48. <!--注册webapp目录为资源目录-->
    49. <resource>
    50. <directory>src/main/webapp</directory>
    51. <targetPath>META-INF/resources</targetPath>
    52. <includes>
    53. <include>**/*.*</include>
    54. </includes>
    55. </resource>
    56. </resources>
    57. <plugins>
    58. <plugin>
    59. <groupId>org.springframework.boot</groupId>
    60. <artifactId>spring-boot-maven-plugin</artifactId>
    61. </plugin>
    62. </plugins>
    63. </build>

    三、创建实体类

    四、创建接口

    五、创建接口实现类

    六、创建dao层

    七、创建mappin文件

    八、配置核心文件

    1. # 视图的前辍与后辍
    2. spring:
    3. mvc:
    4. view:
    5. prefix: /
    6. suffix: .jsp
    7. # 注册数据源
    8. datasource:
    9. type: com.alibaba.druid.pool.DruidDataSource
    10. driver-class-name: com.mysql.jdbc.Driver
    11. url: jdbc:mysql:///test?useUnicode=true&characterEncoding=utf-8
    12. username: root
    13. password: root
    14. #编码设置
    15. http:
    16. encoding:
    17. force: true
    18. charset: utf-8
    19. enabled: true
    20. server:
    21. tomcat:
    22. uri-encoding: UTF-8
    23. mybatis:
    24. # 注册映射文件
    25. mapper-locations: classpath:com/abc/dao/*.xml
    26. # 注册实体类别名
    27. type-aliases-package: com.abc.bean

    九、创建index.jsp文件

    十、创建welcome.jsp文件

    十一、测试

  • 相关阅读:
    ZOJ 3642 多重匹配 离散化.cpp
    POJ 1840 Eqs.cpp 【 Hash 】
    Hdu 4293 DP
    Hlg 1407 【最小点权覆盖】.cpp
    Hdu 3605 多重匹配
    POJ 2195 【二分图最佳匹配】.cpp
    Hdu 4292 Food.cpp 最大流+拆点
    POJ 3469 【最小割】.cpp
    limit_choices_to a value on a field in the same model Google Groups
    Django: limit_choices_to (Is this correct) Stack Overflow
  • 原文地址:https://www.cnblogs.com/edda/p/13261592.html
Copyright © 2020-2023  润新知