1. 程式人生 > 實用技巧 >vue - blog開發學習6

vue - blog開發學習6

vue - blog開發學習6

1、問題,如下圖,使用iviewui中的card導致頁面不能出現滾動條(不太會弄,在網上查了一個vue元件vuescroll,因此使用這個做滾動條)

2、安裝vuescroll

cnpm install -S vuescroll

https://vuescrolljs.yvescoding.org/zh/guide/getting-started.html#%E5%AE%89%E8%A3%85

3、問題:專案使用的jpa操作資料庫,因為postclass和post是多堆多的關係,因此post.java和postclass.java如下,

package com.nxz.blog.entity;

import lombok.Data; import org.hibernate.annotations.GenericGenerator; import javax.persistence.*; import java.util.HashSet; import java.util.Set; @Entity @Data public class Post { @Id @GeneratedValue(generator = "system-uuid") @GenericGenerator(name = "system-uuid", strategy = "uuid") @Column(length
= 32) private String postId; private String postTitle; @Lob private String postContent; /** * 摘要,也就是content的前100個字元 */ private String postRemark; private Long createDate; private Long updateDate; @ManyToMany(fetch = FetchType.LAZY) @JoinTable(name
= "post_postclass", joinColumns = {@JoinColumn(name = "post_id")}, inverseJoinColumns = {@JoinColumn(name = "post_class_id")}) private Set<PostClass> postClasses = new HashSet<>(); }
package com.nxz.blog.entity;

import lombok.Data;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;
import java.util.HashSet;
import java.util.Set;

@Entity
@Data
public class PostClass {

    @Id
    @GeneratedValue(generator = "system-uuid")
    @GenericGenerator(name = "system-uuid", strategy = "uuid")
    @Column(length = 32)
    private String classId;

    @Column(unique = true,length = 50)
    private String className;

    @ManyToMany(mappedBy = "postClasses", fetch = FetchType.LAZY)
    private Set<Post> posts = new HashSet<>();

}

但是當呼叫post.getPostclasses時會出錯,會迴圈輸出一下內容:

HHH000100: Fail-safe cleanup (collections) : [email protected]37b2<[email protected]>
2019-06-11 21:30:16.860  WARN 33728 --- [nio-8888-exec-1] o.h.e.loading.internal.LoadContexts      : HHH000100: Fail-safe cleanup (collections) : [email protected]2b5b<[email protected]>
2019-06-11 21:30:16.860  WARN 33728 --- [nio-8888-exec-1] o.h.e.loading.internal.LoadContexts      : HHH000100: Fail-safe cleanup (collections) : [email protected]60ce<[email protected]>
2019-06-11 21:30:16.860  WARN 33728 --- [nio-8888-exec-1] o.h.e.loading.internal.LoadContexts      : HHH000100: Fail-safe cleanup (collections) : [email protected]d7b1<[email protected]>
2019-06-11 21:30:16.860  WARN 33728 --- [nio-8888-exec-1] o.h.e.loading.internal.LoadContexts      : H

經過查詢資料:https://stackoverflow.com/questions/54946083/jpa-bidirectional-mapping-not-fetching-deep-mapped-data

得知,這個應該是lombok註解@Data導致的,具體原因沒有查明,把這個註解去掉,同時自己手寫get、set方法和tostring方法,就可以了

posted @ 2019-06-12 20:45 巡山小妖N 閱讀(...) 評論(...) 編輯 收藏