SpringBoot———整合Mybatis-xml方式
1.创建Maven工程
1.1pom.xml
1 | <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
1.2mybatis-config.xml
1 | <?xml version="1.0" encoding="UTF-8" ?> |
1.3全局配置文件(applicatiton.properties)
1 | spring: |
1.4pojo以及mapper
1 | //pojo |
1 | //mapper |
1 | //mapper.xml |
2.业务层代码
1 | package net.zzqd.service; |
1 | package net.zzqd.service; |
3.控制层代码
1 | package net.zzqd.controller; |
4.运行
1 | package net.zzqd.app; |
附加:遇到异常:Cannot determine embedded database driver class for database type NONE
暂时未解决
修改后异常:org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘customerController’: Unsatisfied dependency expressed through field ‘customerService’; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘customerServiceImpl’: Unsatisfied dependency expressed through field ‘customerMapper’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘customerMapper’ defined in file [C:\DevelopTools\JavaFramework\SpringBoot_Parent\SpringBoot-Child10\target\classes\net\zzqd\mapper\CustomerMapper.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property ‘sqlSessionFactory’ or ‘sqlSessionTemplate’ are required