[关闭]
@chenbinghua 2019-03-02T06:38:22.000000Z 字数 1547 阅读 701

XMG_springboot

SpringBoot


热部署

  1. <dependency>
  2. <groupId>org.springframework.boot</groupId>
  3. <artifactId>spring-boot-devtools</artifactId>
  4. <optional>true</optional>
  5. </dependency>
  6. spring.devtools.restart.exclude=static/**,templates/**
  7. spring.devtools.restart.additional-exclude=public/** (处理默认配置排除之外的)
  8. spring.devtools.restart.enabled=false (禁用自动重启)

springboot集成mybatis

  1. <!--springboot-mybatis整合包-->
  2. <dependency>
  3. <groupId>org.mybatis.spring.boot</groupId>
  4. <artifactId>mybatis-spring-boot-starter</artifactId>
  5. <version>1.3.2</version>
  6. </dependency>
  7. <!--mysql-jdbc驱动-->
  8. <dependency>
  9. <groupId>mysql</groupId>
  10. <artifactId>mysql-connector-java</artifactId>
  11. <scope>runtime</scope>
  12. </dependency>
  13. <!--druid连接池-->
  14. <dependency>
  15. <groupId>com.alibaba</groupId>
  16. <artifactId>druid</artifactId>
  17. <version>1.0.29</version>
  18. </dependency>
  1. 连接池配置
  2. spring.datasource.url=jdbc:mysql://localhost/jfinal_demo?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull
  3. spring.datasource.password=root
  4. spring.datasource.username=root
  5. spring.datasource.driver-class-name=com.mysql.jdbc.Driver
  6. spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
  7. mybatis配置
  8. mybatis.config-location=classpath:mybatis.cfg.xml
  9. mybatis.mapper-locations=classpath:com/chen/xmgspringboot/_04mybatis/mapper/*Mapper.xml
  10. mybatis.type-aliases-package=com.chen.xmgspringboot._04mybatis.domain

mapper扫描,在启动配置类上tie

  1. @MapperScan("com.chen.xmgspringboot._04mybatis.mapper")

补充知识:
可以在pom文件中的build标签中添加这段配置,让在src下的资源也能加载到classes目录

  1. <resources>
  2. <resource>
  3. <directory>src/main/java</directory>
  4. <includes>
  5. <include>**/*.xml</include>
  6. </includes>
  7. </resource>
  8. </resources>
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注