长春制作门户网站的公司/网站推广软件免费版
我想在springboot中创建一个简单的微服务应用程序。 我的项目包含2个服务。 其中之一是userService,另一个是noteService。
对于每个服务,我想使用一个架构。 这些是userService模式和noteService模式。 一位用户创建了许多笔记。 存在一对多关系。 我无法在2服务之间建立这种关系。 我不明白表格应包含哪些列? 你有什么主意吗? 我的pojo课程如下:
User.java
@Document(collection = "User")
public class User {
@Id
private String id;
private String userName;
public User(String id, String userName) {
this.id = id;
this.userName = userName;
}
public User(){
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
@Override
public String toString() {
return "User{" +
"id='" + id + '\'' +
", userName='" + userName + '\'' +
'}';
}
}
注意.java
@Document(collection = "Note")
public class Note {
@Id
private String id;
private String caption;
private String userNotes;
public Note() {
}
public Note(String id, String caption, String userNotes) {
this.id = id;
this.caption = caption;
this.userNotes = userNotes;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getCaption() {
return caption;
}
public void setCaption(String caption) {
this.caption = caption;
}
public String getUserNotes() {
return userNotes;
}
public void setUserNotes(String userNotes) {
this.userNotes = userNotes;
}
@Override
public String toString() {
return "Note{" +
"id='" + id + '\'' +
", caption='" + caption + '\'' +
", userNotes='" + userNotes + '\'' +
'}';
}
}