vue - blog开发学习6

Posted nxzblogs

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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方法,就可以了

 

以上是关于vue - blog开发学习6的主要内容,如果未能解决你的问题,请参考以下文章

vue - blog开发学习1

vue - blog开发学习5

vue - blog开发学习2

vscode 用户代码片段 vue初始化模板 Snippet #新加入开头注释 自动生成文件名 开发日期时间等内容

《分布式微服务电商》专题-电商项目前端Vue模块化开发

IOS开发-OC学习-常用功能代码片段整理