首页 > 解决方案 > google cloud java app的测试版和部署版效果不同

问题描述

我有一个 Spring Boot 应用程序部署到我的谷歌云。

我的项目中有这个代码......

public void deleteBuyers(Account account, Buyer... buyers) {
    for (Buyer b : buyers) {
        account.getBuyers().remove(b);
    }
    repository.save(account);
}

在帐户中,我有一个买家列表...我需要从帐户中更改买家..所以我从帐户中删除买家,然后在买家上设置新帐户。

但是当我去帐户时。我在旧帐户和新帐户上都设置了买方。

这可能是什么?

上面调用的代码

@Transactional
public void update(Long id, Buyer updatedBuyer) {
    Buyer buyer = find(id);
    Buyer found = repository.findByEmailAndAccount(updatedBuyer.getEmail(), updatedBuyer.getAccount()).orElse(null);
    if (found != null && !found.getId().equals(id)) {
        throw new DataIntegrityException("Comprador já cadastrado");
    }
    accountService.deleteBuyers(buyer.getAccount(), buyer);
    buyer.setEmail(updatedBuyer.getEmail());
    buyer.setTelephone(updatedBuyer.getTelephone());
    buyer.setCreationDate(updatedBuyer.getCreationDate());
    buyer.setExpirationDate(updatedBuyer.getExpirationDate());
    buyer.setAccount(updatedBuyer.getAccount());
    buyer.getAccount().addBuyer(buyer);
    repository.save(buyer);
}

在本地测试时,它可以工作..买方仅在最后设置的帐户上。但是当我上传 jar 时,买家在两个帐户上都设置了

编辑:使用我的 project1 不起作用(datastore southamerica-1) 使用我的 project 2 正在工作(datastore nam5 us-central) 也许数据库位置有错误?

标签: javaspring-bootgoogle-cloud-platformgoogle-cloud-datastore

解决方案


推荐阅读