小编Yas*_*ash的帖子

是否可以在 Spring Boot 中将 MongoDb 和 PostgreSql 用于相同的模型?

我已经构建了一个用户管理服务,我在其中使用 MongoDb(弹簧数据)。我有两个模型用户和角色。

package com.userservice.usermanagement.models;

import java.util.HashSet;
import java.util.Set;

import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.DBRef;
import org.springframework.data.mongodb.core.mapping.Document;

@Document(collection = "user_data")

public class User {
    /**
     * User model
     */
    
      @Id
      private String id;

      
      private String username;

     
      private String email;

      
      private String password;
      
      private String customername;
      
      private String customerid;
      
      private String description;
      

      public String getCustomerid() {
        return customerid;
    }

    public void setCustomerid(String customerid) {
        this.customerid = customerid;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    } …
Run Code Online (Sandbox Code Playgroud)

java postgresql mongodb spring-boot

8
推荐指数
1
解决办法
452
查看次数

标签 统计

java ×1

mongodb ×1

postgresql ×1

spring-boot ×1