Spring use Mybatis
The Spring configuration file applicationContext.xml
- Configure Spring automatic scanning classes
- Configuring a Data Source
SpringMVC configuration file
- MVC: Annotation-Driven Enables Controller annotation support
- MVC: Resources configures static resource mapping rules
- Context :component-scan Scans classes in the Controller package
- Set the JSP path
Configure web. XML
- Load the Spring configuration file
- Load the SpringMVC configuration file
- Encoding filter configuration
SpringBoot use Mybatis
SpringBoot integration Mybatis
<dependency> <groupId>org.mybatis.spring.boot</groudId> <artifactId>mybatis-spring-boot-starter</artifactId> The < version > 1.2.0 < / version > < / dependency >Copy the code
Application.properties configuration file
- Configuring a Data Source
- Configure MyBatis
Url = JDBC :mysql; / / localhost/mybatis spring. The datasource. The username = root spring. The datasource. Password = 092248 # configure mybatis Mybatis. MapperLocations = classpath: mapper / * # XML mapping file mybatis. TypeAliasesPackage = # entity class packageCopy the code