开发笔记
date类型以及返回时间格式
对应的VO类或者是Dao类,添加@JsonFormat注解,返回指定的JSON形式
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
date类型以及返回时间格式
在application.yml文件中添加
mybatis-plus:
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
测试用例的时候,下面的两个注解非常的重要。
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest
public class RedisConfigTest {
}
不然会报NULL
Mapper
mapper-locations: classpath:/mappers/*.xml
这个必须写,不然会有无效的Mapper
Invalid bound statement (not found): com.example.demo.dao.UserMapper.countByUsername
可能是Mapper.xml写的有问题,也是会无效的
可以检查一下包名是否有误
注解RequestBody
@RequestBody
前端使用json方式请求则需要添加的
注解ResponseBody
@ResponseBody
返回json字符串
在使用mybatis generator的时候会出现匹配了很多的表格,并且生成的表格和字段不符合
<!--jdbc的数据库连接 -->
<jdbcConnection
driverClass="${db.driverClassName}"
connectionURL="${db.url}"
userId="${db.username}"
password="${db.password}">
<property name="nullCatalogMeansCurrent" value="true"/>
</jdbcConnection>
因为没有添加
<property name="nullCatalogMeansCurrent" value="true"/>
使用freemarker的模板是的时候无效
依赖:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId>
</dependency>
配置:
spring:
freemarker:
suffix: .ftl
使用:和thymeleaf差不多
@GetMapping("/create")
public ModelAndView create(){
Map map = new HashMap();
map.put("codeUrl","weixin://wxpay/bizpayurl?pr=6Gh4719");
return new ModelAndView("create",map);
}
模板位置:
/resources/templates/
打包是时候,出现test不过的现象
我们可以在maven里面,先把test的功能给禁掉