编程知识 cdmana.com

Spring integrates the configuration files of spring MVC + mybatis basic framework

Catalog
  • Preface
  • 1. Mybatis Layer
  • 2. Spring Layer
    • 1. Spring Integrate Mybatis
    • 2. Spring Integrate service
  • 3. SpringMVC Layer
    • 1. To write web.
    • 2. To write spring-mvc.
  • 4. Spring Configuration integration file ,applicationContext.
  • rely on

Preface

Create a new normal Maven project

Basic directory structure

├── src     	# │ ├── main    	# │ │	└── java   	# java Code directory │ │	└── resources  #  Profile directory ,  Store under Spring The configuration file │ ├── test   		#  Unit test directory ├── web     	# web Catalog │ └── WEB-INF   	# web.


1. Mybatis Layer

1、 stay resources Create a new database configuration file under the directory database.properties

jdbc.driver=com.mysql.jdbc.Driver#  If using  MySQL8.0+  Then you need to add a time zone configuration ; serverTimezone=Asia/Shanghaijdbc.url=jdbc:mysql://localhost:3306/ssmbuild?useSSL=true&useUnicode=true&characterEncoding=utf8jdbc.username=rootjdbc.password=123456

2、 stay resources Create under directory Mybatis The configuration file mybatis-config.

<?


2. Spring Layer

1. Spring Integrate Mybatis

  1. To configure Spring Integrate MyBatis, Here the data source uses c3p0 Connection pool ;

  2. To write Spring Integrate Mybatis Related configuration files of ; stay resources Create under directory spring-dao.

Be careful : Here we're going to introduce the top Mybatis Two configuration files for layer , Don't write the name of the configuration file wrong

<?

2. Spring Integrate service

Inject business layer classes into Spring in , stay resources Create under directory spring-service.

<?


3. SpringMVC Layer

stay resources Create under directory spring-mvc.

<?


rely on

<!-- rely on --><dependencies> <dependency>  <groupId>org.projectlombok</groupId>  <artifactId>lombok</artifactId&g.........

版权声明
本文为[Program ape Owen]所创,转载请带上原文链接,感谢
https://cdmana.com/2021/01/20210131193720938B.html

Scroll to Top