maven实现springboot-mybatis框架(2)

3、配置文件:


application.xml:

# Server settings
#server:
#    port:8080
#    address:localhost


# DATASOURCE
spring:
    datasource:
        name: spring
        url: jdbc:mysql://localhost:3306/spring
        username: root
        password: root


# SPRING PROFILES
      
    # HTTP ENCODING
    http:
        encoding.charset: UTF-8
        encoding.enable: true
        encoding.force: true


# MyBatis
mybatis:
    typeAliasesPackage: my.pojo
    mapperLocations: classpath:/mybatis/mappers/*.xml
    configLocation: classpath:/mybatis/mybatis-config.xml


# LOGGING
logging:
    level:
       com.ibatis:DEBUG

log4j.properties:这个就不贴了,资源很多,自行搜索


mybatis-config.xmlmaven实现springboot-mybatis框架(2)

UserMapper.xml:

maven实现springboot-mybatis框架(2)

pom.xml:

maven实现springboot-mybatis框架(2)

maven实现springboot-mybatis框架(2)

maven实现springboot-mybatis框架(2)

maven实现springboot-mybatis框架(2)

maven实现springboot-mybatis框架(2)



配置完成。

下图是jsp页面

maven实现springboot-mybatis框架(2)

在入口类Application上,run as java application 

运行页面:maven实现springboot-mybatis框架(2)