springboot 整合freemaker+mybatis

配置文件中的内容
#server
server.port=8888
########################################################
###                  \u6570\u636E\u6E90
########################################################
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/excel
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.initialSize=1
spring.datasource.minIdle=1
spring.datasource.maxActive=20

########################################################
###                      MYBATIS
########################################################
mybatis-plus.mapper-locations=classpath:mapper/**Mapper.xml
mybatis-plus.typeAliasesPackage=com/qmx/model
#\u4E3B\u952E\u7C7B\u578B  0:"\u6570\u636E\u5E93ID\u81EA\u589E", 1:"\u7528\u6237\u8F93\u5165ID",2:"\u5168\u5C40\u552F\u4E00ID (\u6570\u5B57\u7C7B\u578B\u552F\u4E00ID)", 3:"\u5168\u5C40\u552F\u4E00ID UUID";
mybatis-plus.global-config.id-type=2
#\u5B57\u6BB5\u7B56\u7565 0:"\u5FFD\u7565\u5224\u65AD",1:"\u975E NULL \u5224\u65AD"),2:"\u975E\u7A7A\u5224\u65AD"
mybatis-plus.global-config.field-strategy=2
#\u9A7C\u5CF0\u4E0B\u5212\u7EBF\u8F6C\u6362
mybatis-plus.global-config.db-column-underline=true
#\u5237\u65B0mapper \u8C03\u8BD5\u795E\u5668
mybatis-plus.global-config.refresh-mapper=true

########################################################
###                      FREEMARKER
########################################################
spring.freemarker.allow-request-override=false
spring.freemarker.cache=true
spring.freemarker.check-template-location=true
spring.freemarker.charset=UTF-8
spring.freemarker.content-type=text/html
spring.freemarker.expose-request-attributes=false
spring.freemarker.expose-session-attributes=false
spring.freemarker.expose-spring-macro-helpers=false
spring.freemarker.request-context-attribute=request
spring.freemarker.suffix=.ftl
spring.freemarker.template-loader-path=classpath:/templates/
spring.freemarker.freemarker-variables.base=#{servletContext.contextPath}
 以下是一基于springboot搭建的freemaker+mybatis 使用的是阿里的数据连接池,放到pom文件里面下载依赖即可使用

<dependency>
    <groupId>org.springframework.bootgroupId>
    <artifactId>spring-boot-starterartifactId>
dependency>
<dependency>
    <groupId>org.springframework.bootgroupId>
    <artifactId>spring-boot-starter-webartifactId>
dependency>
<dependency>
    <groupId>org.springframework.bootgroupId>
    <artifactId>spring-boot-starter-testartifactId>
    <scope>testscope>
dependency>



<dependency>
    <groupId>org.springframework.bootgroupId>
    <artifactId>spring-boot-starter-freemarkerartifactId>
dependency>



<dependency>
    <groupId>org.springframework.bootgroupId>
    <artifactId>spring-boot-starter-jdbcartifactId>
dependency>
<dependency>
    <groupId>com.baomidougroupId>
    <artifactId>mybatisplus-spring-boot-starterartifactId>
    <version>${mybatisplus-spring-boot-starter.version}version>
dependency>
<dependency>
    <groupId>com.baomidougroupId>
    <artifactId>mybatis-plusartifactId>
    <version>${mybatisplus.version}version>
dependency>



<dependency>
    <groupId>com.alibabagroupId>
    <artifactId>druidartifactId>
    <version>1.0.29version>
dependency>
<dependency>
    <groupId>com.alibabagroupId>
    <artifactId>fastjsonartifactId>
    <version>${fastjson.version}version>
dependency>

<dependency>
    <groupId>mysqlgroupId>
    <artifactId>mysql-connector-javaartifactId>
dependency>
然后一个添加一个启动类即可


 
 

你可能感兴趣的:(mybatis,springboot,freemaker)