1. 开启热部署
在IDE开启自动编译的情况下,在POM.XML中加入依赖项:
<!-- 热部署-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
重启应用.
附上IDEA开启自动编译的方法:
1) “File” -> “Settings” -> “Build,Execution,Deplyment” -> “Compiler”,选中打勾 “Build project automatically” 。
2) 组合键:“Shift+Ctrl+Alt+/” ,选择 “Registry” ,选中打勾 “compiler.automake.allow.when.app.running” 。
2. 开启HTML5 不严格语法
默认不开启,需要每个标签都有对应的闭合标签,否则就报错,开启方法:
(1) 在application.properties中增加:
spring.thymeleaf.content-type=text/html
spring.thymeleaf.cache=false
spring.thymeleaf.mode =LEGACYHTML5
(2) 在pom中增加:
<dependency>
<groupId>net.sourceforge.nekohtml</groupId>
<artifactId>nekohtml</artifactId>
<version>1.9.22</version>
</dependency>
3. springboot 整合mybatis后如何打印日志
最近做项目时想打印sql语句供分析,网上各种方法都试验了,只有下面的可以用,在application.yml中进行如下配置,重点是log-impl:
mybatis:
typeAliasesPackage: com.jd.ptest
mapperLocations: classpath:/mapper/*Mapper.xml
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl