JAVA開發遇到的問題(一)

1.@JsonFormat解決時間格式不規範

數據庫返回的數據:

在Bean類中設置:@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")

修改後返回的數據:

 

2.BeanUtils.copyProperties無法複製date類型

user對象和formBean對象都有屬性birthday,而且都是java.sql.Date類型的

當進行BeanUtils.copyProperties(user,formBean);複製屬性時候,formBean中屬性birthday爲null

2.1手動添加數據:

2.2導入import org.dozer.Mapper

在pom配置

<dependency>
    <groupId>net.sf.dozer</groupId>
    <artifactId>dozer</artifactId>
    <version>5.5.1</version>
</dependency>
<dependency>
    <groupId>net.sf.dozer</groupId>
    <artifactId>dozer-spring</artifactId>
    <version>5.5.1</version>
</dependency>                                                                           

3.Mapper中報Could not autowire. No beans of 'UserMapper' type found.

在配置中把這個Autowiring for Bean Class選項取消

 

 

 

 

 

 

 

 

發佈了236 篇原創文章 · 獲贊 48 · 訪問量 20萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章