Spring Boot API 错误地重复 SQL 数据

Posted

技术标签:

【中文标题】Spring Boot API 错误地重复 SQL 数据【英文标题】:Spring Boot API repeating SQL data incorrectly 【发布时间】:2020-01-17 15:42:08 【问题描述】:

我有一个来自 Spring-boot 的 API,它成功连接到我的 SQL 数据库。 我有一个大型数据集 224,并且从 get 请求中显示的数据重复。

它正确地重复前 7 个项目,然后重复它们,然后正确添加第 15 个插槽,然后它混合了重复前 7 个项目和剩余插槽的 15 个插槽。

对此的任何帮助将不胜感激,因为我很难过。 :( 我在下面包含了所有可能有帮助的代码。

问题是每224张卡的卡数据不同,在mysql中是正确的,但是在springboot API中用GET函数查看数据时,数据重复了卡的第一个元素,即不正确。 mysql 数据中没有任何内容是键,id、imglocation、name 列是唯一的字符串(并且都是不同的),但这在 SQL 表中没有说明

Card.java

import javax.persistence.*;

@Entity
@Table(name = "cards")
public class Card 

    @Id

    String clan;
    int cost;
    int decklimit;
    String element;
    int fate;
    int glory;
    int honor;
    String id;
    String imglocation;
    int influencecost;
    int influencepool;
    String isrestricted;
    int military;
    String militarybonus;
    String name;
    int political;
    String politicalbonus;
    String rolerestriction;
    String side;
    int strength;
    String strengthbonus;
    String text;
    String typeof;
    String unicity;

GETTERS 和 SETTERS 已编辑

卡库

import org.springframework.data.jpa.repository.JpaRepository;
import com.name.models.Card;

public interface CardRepository extends JpaRepository<Card, String>



application.properties

server.port=9000

spring.jpa.hibernate.ddl-auto=update
spring.datasource.url=jdbc:mysql://IP-redacted:3306/SQL-table-name-redacted?useSSL=false
spring.datasource.username=redacted
spring.datasource.password=redacted

spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect

卡控制器

import com.name.repository.CardRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.name.models.Card;

import java.util.List;

@CrossOrigin
@RestController
public class CardController 

    @Autowired
    private CardRepository repository;

    @RequestMapping(value = "cards", method = RequestMethod.GET)
    public List<Card> listAllCards()
        return repository.findAll();
    

MYSQL 表

 Field           | Type         | Null | Key | Default | Extra |
+-----------------+--------------+------+-----+---------+-------+
| clan            | varchar(8)   | NO   |     | NULL    |       |
| cost            | int(11)      | NO   |     | NULL    |       |
| decklimit       | int(11)      | NO   |     | NULL    |       |
| element         | varchar(5)   | NO   |     | NULL    |       |
| fate            | int(11)      | NO   |     | NULL    |       |
| glory           | int(11)      | NO   |     | NULL    |       |
| honor           | int(11)      | NO   |     | NULL    |       |
| id              | varchar(40)  | NO   |     | NULL    |       |
| imglocation     | varchar(80)  | NO   |     | NULL    |       |
| influencecost   | int(11)      | NO   |     | NULL    |       |
| influencepool   | int(11)      | NO   |     | NULL    |       |
| isrestricted    | varchar(5)   | YES  |     | NULL    |       |
| military        | int(11)      | NO   |     | NULL    |       |
| militarybonus   | varchar(2)   | NO   |     | NULL    |       |
| name            | varchar(40)  | NO   |     | NULL    |       |
| political       | int(11)      | NO   |     | NULL    |       |
| politicalbonus  | varchar(2)   | NO   |     | NULL    |       |
| rolerestriction | varchar(6)   | NO   |     | NULL    |       |
| side            | varchar(8)   | NO   |     | NULL    |       |
| strength        | int(11)      | NO   |     | NULL    |       |
| strengthbonus   | varchar(2)   | NO   |     | NULL    |       |
| text            | varchar(500) | YES  |     | NULL    |       |
| typeof          | varchar(10)  | NO   |     | NULL    |       |
| unicity         | varchar(5)   | YES  |     | NULL    |       |

数据

`["clan":"crab","cost":0,"decklimit":1,"element":"","fate":7,"glory":0,"honor":10,"id":"shiro-nishiyama","imglocation":"http://lcg-cdn.fantasyflightgames.com/l5r/L5C01_1.jpg","influencecost":0,"influencepool":10,"isrestricted":"false","military":0,"militarybonus":"","name":"Shiro Nishiyama","political":0,"politicalbonus":"","rolerestriction":"","side":"province","strength":0,"strengthbonus":"+3","text":"<b>Action:</b> During a conflict, bow this stronghold - each defending character you control gets +1[conflict-military] and +1[conflict-political] until the end of the conflict.","typeof":"stronghold","unicity":"true","clan":"crane","cost":0,"decklimit":1,"element":"","fate":7,"glory":0,"honor":11,"id":"shizuka-toshi","imglocation":"http://lcg-cdn.fantasyflightgames.com/l5r/L5C01_2.jpg","influencecost":0,"influencepool":10,"isrestricted":"false","military":0,"militarybonus":"","name":"Shizuka Toshi","political":0,"politicalbonus":"","rolerestriction":"","side":"province","strength":0,"strengthbonus":"+2","text":"<b>Action:</b> During a [conflict-political] conflict, bow this stronghold. Choose a participating character with [conflict-political] skill 2 or lower - bow that character.","typeof":"stronghold","unicity":"true",`"clan":"dragon","cost":0,"decklimit":1,"element":"","fate":7,"glory":0,"honor":11,"id":"mountain-s-anvil-castle","imglocation":"http://lcg-cdn.fantasyflightgames.com/l5r/L5C01_3.jpg","influencecost":0,"influencepool":10,"isrestricted":"false","military":0,"militarybonus":"","name":"Mountain's Anvil Castle","political":0,"politicalbonus":"","rolerestriction":"","side":"province","strength":0,"strengthbonus":"+2","text":"<b>Action:</b> During a conflict, bow this stronghold. Choose a participating character with 1 or more attachments on it - until the end of the conflict, that character gets +1[conflict-military] and +1[conflict-political] (+2[conflict-military] and +2[conflict-political] instead if it has 2 or more attachments on it).","typeof":"stronghold","unicity":"true","clan":"lion","cost":0,"decklimit":1,"element":"","fate":7,"glory":0,"honor":12,"id":"yojin-no-shiro","imglocation":"http://lcg-cdn.fantasyflightgames.com/l5r/L5C01_4.jpg","influencecost":0,"influencepool":10,"isrestricted":"false","military":0,"militarybonus":"","name":"Y?jin no Shiro","political":0,"politicalbonus":"","rolerestriction":"","side":"province","strength":0,"strengthbonus":"+2","text":"<b>Action:</b> During a conflict, bow this stronghold - each attacking character you control gets +1[conflict-military] until the end of the conflict.","typeof":"stronghold","unicity":"true",`"clan":"phoenix","cost":0,"decklimit":1,"element":"","fate":7,"glory":0,"honor":11,"id":"isawa-mori-seido","imglocation":"http://lcg-cdn.fantasyflightgames.com/l5r/L5C01_5.jpg","influencecost":0,"influencepool":10,"isrestricted":"false","military":0,"militarybonus":"","name":"Isawa Mori Seid?","political":0,"politicalbonus":"","rolerestriction":"","side":"province","strength":0,"strengthbonus":"+2","text":"<b>Action:</b> Bow this stronghold, choose a character - that character gets +2 glory until the end of the phase.","typeof":"stronghold","unicity":"true","clan":"scorpion","cost":0,"decklimit":1,"element":"","fate":7,"glory":0,"honor":10,"id":"city-of-the-open-hand","imglocation":"http://lcg-cdn.fantasyflightgames.com/l5r/L5C01_6.jpg","influencecost":0,"influencepool":10,"isrestricted":"false","military":0,"militarybonus":"","name":"City of the Open Hand","political":0,"politicalbonus":"","rolerestriction":"","side":"province","strength":0,"strengthbonus":"+1","text":"<b>Action:</b> If you are less honorable than an opponent, bow this stronghold and select one - either that opponent loses 1 honor, or you gain 1 honor.\n<i>Errata from RRG v9</i>","typeof":"stronghold","unicity":"true",`"clan":"unicorn","cost":0,"decklimit":1,"element":"","fate":7,"glory":0,"honor":10,"id":"golden-plains-outpost","imglocation":"http://lcg-cdn.fantasyflightgames.com/l5r/L5C01_7.jpg","influencecost":0,"influencepool":10,"isrestricted":"false","military":0,"militarybonus":"","name":"Golden Plains Outpost","political":0,"politicalbonus":"","rolerestriction":"","side":"province","strength":0,"strengthbonus":"+0","text":"<b>Action:</b> During a [conflict-military] conflict, bow this stronghold. Choose a <em>Cavalry</em> character you control - move it to that conflict.","typeof":"stronghold","unicity":"true","clan":"crab","cost":0,"decklimit":1,"element":"","fate":7,"glory":0,"honor":10,"id":"shiro-nishiyama","imglocation":"http://lcg-cdn.fantasyflightgames.com/l5r/L5C01_1.jpg","influencecost":0,"influencepool":10,"isrestricted":"false","military":0,"militarybonus":"","name":"Shiro Nishiyama","political":0,"politicalbonus":"","rolerestriction":"","side":"province","strength":0,"strengthbonus":"+3","text":"<b>Action:</b> During a conflict, bow this stronghold - each defending character you control gets +1[conflict-military] and +1[conflict-political] until the end of the conflict.","typeof":"stronghold","unicity":"true",`"clan":"crane","cost":0,"decklimit":1,"element":"","fate":7,"glory":0,"honor":11,"id":"shizuka-toshi","imglocation":"http://lcg-cdn.fantasyflightgames.com/l5r/L5C01_2.jpg","influencecost":0,"influencepool":10,"isrestricted":"false","military":0,"militarybonus":"","name":"Shizuka Toshi","political":0,"politicalbonus":"","rolerestriction":"","side":"province","strength":0,"strengthbonus":"+2","text":"<b>Action:</b> During a [conflict-political] conflict, bow this stronghold. Choose a participating character with [conflict-political] skill 2 or lower - bow that character.","typeof":"stronghold","unicity":"true","clan":"dragon","cost":0,"decklimit":1,"element":"","fate":7,"glory":0,"honor":11,"id":"mountain-s-anvil-castle","imglocation":"http://lcg-cdn.fantasyflightgames.com/l5r/L5C01_3.jpg","influencecost":0,"influencepool":10,"isrestricted":"false","military":0,"militarybonus":"","name":"Mountain's Anvil Castle","political":0,"politicalbonus":"","rolerestriction":"","side":"province","strength":0,"strengthbonus":"+2","text":"<b>Action:</b> During a conflict, bow this stronghold. Choose a participating character with 1 or more attachments on it - until the end of the conflict, that character gets +1[conflict-military] and +1[conflict-political] (+2[conflict-military] and +2[conflict-political] instead if it has 2 or more attachments on it).","typeof":"stronghold","unicity":"true",`"clan":"lion","cost":0,"decklimit":1,"element":"","fate":7,"glory":0,"honor":12,"id":"yojin-no-shiro","imglocation":"http://lcg-cdn.fantasyflightgames.com/l5r/L5C01_4.jpg","influencecost":0,"influencepool":10,"isrestricted":"false","military":0,"militarybonus":"","name":"Y?jin no Shiro","political":0,"politicalbonus":"","rolerestriction":"","side":"province","strength":0,"strengthbonus":"+2","text":"<b>Action:</b> During a conflict, bow this stronghold - each attacking character you control gets +1[conflict-military] until the end of the conflict.","typeof":"stronghold","unicity":"true","clan":"phoenix","cost":0,"decklimit":1,"element":"","fate":7,"glory":0,"honor":11,"id":"isawa-mori-seido","imglocation":"http://lcg-cdn.fantasyflightgames.com/l5r/L5C01_5.jpg","influencecost":0,"influencepool":10,"isrestricted":"false","military":0,"militarybonus":"","name":"Isawa Mori Seid?","political":0,"politicalbonus":"","rolerestriction":"","side":"province","strength":0,"strengthbonus":"+2","text":"<b>Action:</b> Bow this stronghold, choose a character - that character gets +2 glory until the end of the phase.","typeof":"stronghold","unicity":"true",`"clan":"scorpion","cost":0,"decklimit":1,"element":"","fate":7,"glory":0,"honor":10,"id":"city-of-the-open-hand","imglocation":"http://lcg-cdn.fantasyflightgames.com/l5r/L5C01_6.jpg","influencecost":0,"influencepool":10,"isrestricted":"false","military":0,"militarybonus":"","name":"City of the Open Hand","political":0,"politicalbonus":"","rolerestriction":"","side":"province","strength":0,"strengthbonus":"+1","text":"<b>Action:</b> If you are less honorable than an opponent, bow this stronghold and select one - either that opponent loses 1 honor, or you gain 1 honor.\n<i>Errata from RRG v9</i>","typeof":"stronghold","unicity":"true","clan":"unicorn","cost":0,"decklimit":1,"element":"","fate":7,"glory":0,"honor":10,"id":"golden-plains-outpost","imglocation":"http://lcg-cdn.fantasyflightgames.com/l5r/L5C01_7.jpg","influencecost":0,"influencepool":10,"isrestricted":"false","military":0,"militarybonus":"","name":"Golden Plains Outpost","political":0,"politicalbonus":"","rolerestriction":"","side":"province","strength":0,"strengthbonus":"+0","text":"<b>Action:</b> During a [conflict-military] conflict, bow this stronghold. Choose a <em>Cavalry</em> character you control - move it to that conflict.","typeof":"stronghold","unicity":"true",`"clan":"neutral","cost":0,"decklimit":1,"element":"earth","fate":0,"glory":0,"honor":0,"id":"ancestral-lands","imglocation":"http://lcg-cdn.fantasyflightgames.com/l5r/L5C01_15.jpg","influencecost":0,"influencepool":0,"isrestricted":"false","military":0,"militarybonus":"","name":"Ancestral Lands","political":0,"politicalbonus":"","rolerestriction":"","side":"province","strength":5,"strengthbonus":"","text":"This province gets +5 strength during [conflict-political] conflicts.","typeof":"province","unicity":"false","clan":"neutral","cost":0,"decklimit":1,"element":"earth","fate":0,"glory":0,"honor":0,"id":"ancestral-lands","imglocation":"http://lcg-cdn.fantasyflightgames.com/l5r/L5C01_15.jpg","influencecost":0,"influencepool":0,"isrestricted":"false","military":0,"militarybonus":"","name":"Ancestral Lands","political":0,"politicalbonus":"","rolerestriction":"","side":"province","strength":5,"strengthbonus":"","text":"This province gets +5 strength during [conflict-political] conflicts.","typeof":"province","unicity":"false",`"clan":"neutral","cost":0,"decklimit":1,"element":"earth","fate":0,"glory":0,"honor":0,"id":"ancestral-lands","imglocation":"http://lcg-cdn.fantasyflightgames.com/l5r/L5C01_15.jpg","influencecost":0,"influencepool":0,"isrestricted":"false","military":0,"militarybonus":"","name":"Ancestral Lands","political":0,"politicalbonus":"","rolerestriction":"","side":"province","strength":5,"strengthbonus":"","text":"This province gets +5 strength during [conflict-political] conflicts.","typeof":"province","unicity":"false","clan":"neutral","cost":0,"decklimit":1,"element":"earth","fate":0,"glory":0,"honor":0,"id":"ancestral-lands","imglocation":"http://lcg-cdn.fantasyflightgames.com/l5r/L5C01_15.jpg","influencecost":0,"influencepool":0,"isrestricted":"false","military":0,"militarybonus":"","name":"Ancestral Lands","political":0,"politicalbonus":"","rolerestriction":"","side":"province","strength":5,"strengthbonus":"","text":"This province gets +5 strength during [conflict-political] conflicts.","typeof":"province","unicity":"false",`"clan":"neutral","cost":0,"decklimit":1,"element":"earth","fate":0,"glory":0,"honor":0,"id":"ancestral-lands","imglocation":"http://lcg-cdn.fantasyflightgames.com/l5r/L5C01_15.jpg","influencecost":0,"influencepool":0,"isrestricted":"false","military":0,"militarybonus":"","name":"Ancestral Lands","political":0,"politicalbonus":"","rolerestriction":"","side":"province","strength":5,"strengthbonus":"","text":"This province gets +5 strength during [conflict-political] conflicts.","typeof":"province","unicity":"false","clan":"neutral","cost":0,"decklimit":1,"element":"earth","fate":0,"glory":0,"honor":0,"id":"ancestral-lands","imglocation":"http://lcg-cdn.fantasyflightgames.com/l5r/L5C01_15.jpg","influencecost":0,"influencepool":0,"isrestricted":"false","military":0,"militarybonus":"","name":"Ancestral Lands","political":0,"politicalbonus":"","rolerestriction":"","side":"province","strength":5,"strengthbonus":"","text":"This province gets +5 strength during [conflict-political] conflicts.","typeof":"province","unicity":"false",`"clan":"neutral","cost":0,"decklimit":1,"element":"earth","fate":0,"glory":0,"honor":0,"id":"ancestral-lands","imglocation":"http://lcg-cdn.fantasyflightgames.com/l5r/L5C01_15.jpg","influencecost":0,"influencepool":0,"isrestricted":"false","military":0,"militarybonus":"","name":"Ancestral Lands","political":0,"politicalbonus":"","rolerestriction":"","side":"province","strength":5,"strengthbonus":"","text":"This province gets +5 strength during [conflict-political] conflicts.","typeof":"province","unicity":"false","clan":"neutral","cost":0,"decklimit":1,"element":"earth","fate":0,"glory":0,"honor":0,"id":"ancestral-lands","imglocation":"http://lcg-cdn.fantasyflightgames.com/l5r/L5C01_15.jpg","influencecost":0,"influencepool":0,"isrestricted":"false","military":0,"militarybonus":"","name":"Ancestral Lands","political":0,"politicalbonus":"","rolerestriction":"","side":"province","strength":5,"strengthbonus":"","text":"This province gets +5 strength during [conflict-political] conflicts.","typeof":"province","unicity":"false",`"clan":"neutral","cost":0,"decklimit":1,"element":"earth","fate":0,"glory":0,"honor":0,"id":"ancestral-lands","imglocation":"http://lcg-cdn.fantasyflightgames.com/l5r/L5C01_15.jpg","influencecost":0,"influencepool":0,"isrestricted":"false","military":0,"militarybonus":"","name":"Ancestral Lands","political":0,"politicalbonus":"","rolerestriction":"","side":"province","strength":5,"strengthbonus":"","text":"This province gets +5 strength during [conflict-political] conflicts.","typeof":"province","unicity":"false","clan":"neutral","cost":0,"decklimit":1,"element":"earth","fate":0,"glory":0,"honor":0,"id":"ancestral-lands","imglocation":"http://lcg-cdn.fantasyflightgames.com/l5r/L5C01_15.jpg","influencecost":0,"influencepool":0,"isrestricted":"false","military":0,"militarybonus":"","name":"Ancestral Lands","political":0,"politicalbonus":"","rolerestriction":"","side":"province","strength":5,"strengthbonus":"","text":"This province gets +5 strength during [conflict-political] conflicts.","typeof":"province","unicity":"false",`"clan":"crab","cost":0,"decklimit":1,"element":"","fate":7,"glory":0,"honor":10,"id":"shiro-nishiyama","imglocation":"http://lcg-cdn.fantasyflightgames.com/l5r/L5C01_1.jpg","influencecost":0,"influencepool":10,"isrestricted":"false","military":0,"militarybonus":"","name":"Shiro Nishiyama","political":0,"politicalbonus":"","rolerestriction":"","side":"province","strength":0,"strengthbonus":"+3","text":"<b>Action:</b> During a conflict, bow this stronghold - each defending character you control gets +1[conflict-military] and +1[conflict-political] until the end of the conflict.","typeof":"stronghold","unicity":"true","clan":"crab","cost":0,"decklimit":1,"element":"","fate":7,"glory":0,"honor":10,"id":"shiro-nishiyama","imglocation":"http://lcg-cdn.fantasyflightgames.com/l5r/L5C01_1.jpg","influencecost":0,"influencepool":10,"isrestricted":"false","military":0,"militarybonus":"","name":"Shiro Nishiyama","political":0,"politicalbonus":"","rolerestriction":"","side":"province","strength":0,"strengthbonus":"+3","text":"<b>Action:</b> During a conflict, bow this stronghold - each defending character you control gets +1[conflict-military] and +1[conflict-political] until the end of the conflict.","typeof":"stronghold","unicity":"true",`"clan":"crab","cost":0,"decklimit":1,"element":"","fate":7,"glory":0,"honor":10,"id":"shiro-nishiyama","imglocation":"http://lcg-cdn.fantasyflightgames.com/l5r/L5C01_1.jpg","influencecost":0,"influencepool":10,"isrestricted":"false","military":0,"militarybonus":"","name":"Shiro Nishiyama","political":0,"politicalbonus":"","rolerestriction":"","side":"province","strength":0,"strengthbonus":"+3","text":"<b>Action:</b> During a conflict, bow this stronghold - each defending character you control gets +1[conflict-military] and +1[conflict-political] until the end of the conflict.","typeof":"stronghold","unicity":"true","clan":"crab","cost":0,"decklimit":1,"element":"","fate":7,"glory":0,"honor":10,"id":"shiro-nishiyama","imglocation":"http://lcg-cdn.fantasyflightgames.com/l5r/L5C01_1.jpg","influencecost":0,"influencepool":10,"isrestricted":"false","military":0,"militarybonus":"","name":"Shiro Nishiyama","political":0,"politicalbonus":"","rolerestriction":"","side":"province","strength":0,"strengthbonus":"+3","text":"<b>Action:</b> During a conflict, bow this stronghold - each defending character you control gets +1[conflict-military] and +1[conflict-political] until the end of the conflict.","typeof":"stronghold","unicity":"true",`"clan":"crab","cost":0,"decklimit":1,"element":"","fate":7,"glory":0,"honor":10,"id":"shiro-nishiyama","imglocation":"http://lcg-cdn.fantasyflightgames.com/l5r/L5C01_1.jpg","influencecost":0,"influencepool":10,"isrestricted":"false","military":0,"militarybonus":"","name":"Shiro Nishiyama","political":0,"politicalbonus":"","rolerestriction":"","side":"province","strength":0,"strengthbonus":"+3","text":"<b>Action:</b> During a conflict, bow this stronghold - each defending character you control gets +1[conflict-military] and +1[conflict-political] until the end of the conflict.","typeof":"stronghold","unicity":"true","clan":"crab","cost":0,"decklimit":1,"element":"","fate":7,"glory":0,"honor":10,"id":"shiro-nishiyama","imglocation":"http://lcg-cdn.fantasyflightgames.com/l5r/L5C01_1.jpg","influencecost":0,"influencepool":10,"isrestricted":"false","military":0,"militarybonus":"","name":"Shiro Nishiyama","political":0,"politicalbonus":"","rolerestriction":"","side":"province","strength":0,"strengthbonus":"+3","text":"<b>Action:</b> During a conflict, bow this stronghold - each defending character you control gets +1[conflict-military] and +1[conflict-political] until the end of the conflict.","typeof":"stronghold","unicity":"true",`"clan":"crab","cost":0,"decklimit":1,"element":"","fate":7,"glory":0,"honor":10,"id":"shiro-nishiyama","imglocation":"http://lcg-cdn.fantasyflightgames.com/l5r/L5C01_1.jpg","influencecost":0,"influencepool":10,"isrestricted":"false","military":0,"militarybonus":"","name":"Shiro Nishiyama","political":0,"politicalbonus":"","rolerestriction":"","side":"province","strength":0,"strengthbonus":"+3","text":"<b>Action:</b> During a conflict, bow this stronghold - each defending character you control gets +1[conflict-military] and +1[conflict-political] until the end of the conflict.","typeof":"stronghold","unicity":"true","clan":"crab","cost":0,"decklimit":1,"element":"","fate":7,"glory":0,"honor":10,"id":"shiro-nishiyama","imglocation":"http://lcg-cdn.fantasyflightgames.com/l5r/L5C01_1.jpg","influencecost":0,"influencepool":10,"isrestricted":"false","military":0,"militarybonus":"","name":"Shiro Nishiyama","political":0,"politicalbonus":"","rolerestriction":"","side":"province","strength":0,"strengthbonus":"+3","text":"<b>Action:</b> During a conflict, bow this stronghold - each defending character you control gets +1[conflict-military] and +1[conflict-political] until the end of the conflict.","typeof":"stronghold","unicity":"true",`"clan":"crab","cost":0,"decklimit":1,"element":"","fate":7,"glory":0,"honor":10,"id":"shiro-nishiyama","imglocation":"http://lcg-cdn.fantasyflightgames.com/l5r/L5C01_1.jpg","influencecost":0,"influencepool":10,"isrestricted":"false","military":0,"militarybonus":"","name":"Shiro Nishiyama","political":0,"politicalbonus":"","rolerestriction":"","side":"province","strength":0,"strengthbonus":"+3","text":"<b>Action:</b> During a conflict, bow this stronghold - each defending character you control gets +1[conflict-military] and +1[conflict-political] until the end of the conflict.","typeof":"stronghold","unicity":"true","clan":"crab","cost":0,"decklimit":1,"element":"","fate":7,"glory":0,"honor":10,"id":"shiro-nishiyama","imglocation":"http://lcg-cdn.fantasyflightgames.com/l5r/L5C01_1.jpg","influencecost":0,"influencepool":10,"isrestricted":"false","military":0,"militarybonus":"","name":"Shiro Nishiyama","political":0,"politicalbonus":"","rolerestriction":"","side":"province","strength":0,"strengthbonus":"+3","text":"<b>Action:</b> During a conflict, bow this stronghold - each defending character you control gets +1[conflict-military] and +1[conflict-political] until the end of the conflict.","typeof":"stronghold","unicity":"true","clan":"crab","cost":0,"decklimit":1,"element":"","fate":7,"glory":0,"honor":10,"id":"shiro-nishiyama","imglocation":"http://lcg-cdn.fantasyflightgames.com/l5r/L5C01_1.jpg","influencecost":0,"influencepool":10,"isrestricted":"false","military":0,"militarybonus":"","name":"Shiro Nishiyama","political":0,"politicalbonus":"","rolerestriction":"","side":"province","strength":0,"strengthbonus":"+3","text":"<b>Action:</b> During a conflict, bow this stronghold - each defending character you control gets +1[conflict-military] and +1[conflict-political] until the end of the conflict.","typeof":"stronghold","unicity":"true","clan":"crab","cost":0,"decklimit":1,"element":"","fate":7,"glory":0,"honor":10,"id":"shiro-nishiyama","imglocation":"http://lcg-cdn.fantasyflightgames.com/l5r/L5C01_1.jpg","influencecost":0,"influencepool":10,"isrestricted":"false","military":0,"militarybonus":"","name":"Shiro Nishiyama","political":0,"politicalbonus":"","rolerestriction":"","side":"province","strength":0,"strengthbonus":"+3","text":"<b>Action:</b> During a conflict, bow this stronghold - each defending character you control gets +1[conflict-military] and +1[conflict-political] until the end of the conflict.","typeof":"stronghold","unicity":"true","clan":"crab","cost":0,"decklimit":1,"element":"","fate":7,"glory":0,"honor":10,"id":"shiro-nishiyama","imglocation":"http://lcg-cdn.fantasyflightgames.com/l5r/L5C01_1.jpg","influencecost":0,"influencepool":10,"isrestricted":"false","military":0,"militarybonus":"","name":"Shiro Nishiyama","political":0,"politicalbonus":"","rolerestriction":"","side":"province","strength":0,"strengthbonus":"+3","text":"<b>Action:</b> During a conflict, bow this stronghold - each defending character you control gets +1[conflict-military] and +1[conflict-political] until the end of the conflict.","typeof":"stronghold","unicity":"true","clan":"crab","cost":0,"decklimit":1,"element":"","fate":7,"glory":0,"honor":10,"id":"shiro-nishiyama","imglocation":"http://lcg-cdn.fantasyflightgames.com/l5r/L5C01_1.jpg","influencecost":0,"influencepool":10,"isrestricted":"false","military":0,"militarybonus":"","name":"Shiro Nishiyama","political":0,"politicalbonus":"","rolerestriction":"","side":"province","strength":0,"strengthbonus":"+3","text":"<b>Action:</b> During a conflict, bow this stronghold - each defending character you control gets +1[conflict-military] and +1[conflict-political] until the end of the conflict.","typeof":"stronghold","unicity":"true","clan":"crab","cost":0,"decklimit":1,"element":"","fate":7,"glory":0,"honor":10,"id":"shiro-nishiyama","imglocation":"http://lcg-cdn.fantasyflightgames.com/l5r/L5C01_1.jpg","influencecost":0,"influencepool":10,"isrestricted":"false","military":0,"militarybonus":"","name":"Shiro Nishiyama","political":0,"politicalbonus":"","rolerestriction":"","side":"province","strength":0,"strengthbonus":"+3","text":"<b>Action:</b> During a conflict, bow this stronghold - each defending character you control gets +1[conflict-military] and +1[conflict-political] until the end of the conflict.","typeof":"stronghold","unicity":"true","clan":"crane","cost":0,"decklimit":1,"element":"","fate":7,"glory":0,"honor":11,"id":"shizuka-toshi","imglocation":"http://lcg-cdn.fantasyflightgames.com/l5r/L5C01_2.jpg","influencecost":0,"influencepool":10,"isrestricted":"false","military":0,"militarybonus":"","name":"Shizuka Toshi","political":0,"politicalbonus":"","rolerestriction":"","side":"province","strength":0,"strengthbonus":"+2","text":"<b>Action:</b> During a [conflict-political] conflict, bow this stronghold. Choose a participating character with [conflict-political] skill 2 or lower - bow that character.","typeof":"stronghold","unicity":"true"

【问题讨论】:

嗨乔纳森,目前还不清楚问题是什么。不确定在这种情况下重复的项目和插槽是什么意思。你能详细说明这个问题吗?预期的结果是什么?你看到的是什么? 你能给我们看看实际数据吗?部落字段是您数据库中的主键吗?它是独一无二的吗? 已添加数据以显示它们作为 JSON 对象的外观 - 这是我看到问题的地方 - 如您所见 - 例如,数据正在重复“shiro nishiyama”。 您能分享一下 db 中可用的数据吗?谢谢 问题是每个224卡的卡数据不一样,在mysql中是正确的,但是在springboot API用GET函数查看数据时,数据重复了第一个元素不正确的牌。 mysql 数据中没有任何内容是键,id、imglocation、name 列是唯一的字符串(并且都是不同的),但这在 SQL 表中没有说明。 【参考方案1】:

已解决:

@id 选择的是 'clan' 而不是 'id'。

@Id
    String id;

【讨论】:

以上是关于Spring Boot API 错误地重复 SQL 数据的主要内容,如果未能解决你的问题,请参考以下文章

在 Spring Boot 中使用 Web Client Mono 获取 API 响应错误消息

部署到 Tomcat 10 后无法访问 Spring Boot 应用程序 [重复]

spring boot 通过AOP防止API重复请求

使用 Spring Boot 创建 REST API [重复]

Java Spring Boot将rest api映射到模型[重复]

如何通过start-stop-daemon优雅地关闭Spring Boot应用程序[重复]