Spring JPA存储库方法不返回任何数据,即使数据存在于H2 db中

Spring JPA存储库方法不返回任何数据,即使数据存在于H2 db中,spring,spring-boot,spring-data-jpa,Spring,Spring Boot,Spring Data Jpa,exchangeValue为null,但数据以h2 db的形式存在 我的代码url是 谁能帮我一下吗?数据库中存在数据 我打这个rest电话是为了获取数据 package com.sunny.microservices.currencyexchangeservice; import java.math.BigDecimal; import javax.persistence.Column; import javax.persistence.Entity; import javax.pers

exchangeValue为null,但数据以h2 db的形式存在

我的代码url是

谁能帮我一下吗?数据库中存在数据

我打这个rest电话是为了获取数据

package com.sunny.microservices.currencyexchangeservice;

import java.math.BigDecimal;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;

@Entity
public class ExchangeValue {

@Id
private Long id;

@Column(name = "currency_from")
private String from;

@Column(name = "currency_to")
private String to;

private BigDecimal conversionMultiple;
private int port;

public ExchangeValue() {

}

public ExchangeValue(Long id, String from, String to, BigDecimal conversionMultiple) {
    super();
    this.id = id;
    this.from = from;
    this.to = to;
    this.conversionMultiple = conversionMultiple;
}

public Long getId() {
    return id;
}

public String getFrom() {
    return from;
}

public String getTo() {
    return to;
}

public BigDecimal getConversionMultiple() {
    return conversionMultiple;
}

public int getPort() {
    return port;
}

public void setPort(int port) {
    this.port = port;
}

}

如果需要其他数据,请告诉我。

非常简单。在data.sql中插入了大写值。尝试使用
http://localhost:8001/currency-交换/from/USD/to/INR
或在data.sql中将其更改为小写。

rest调用中存在Hi问题。这是区分大小写的错误

正确的选择应该是

http://localhost:8001/currency-exchange/from/usd/to/inr
而不是

http://localhost:8001/currency-exchange/from/USD/to/INR

这是一个对案件敏感的问题: 将美元换成美元,印度卢比换成印度卢比

召唤


show ExchangeValue entityRecheck您有来自和到的数据,如果没有匹配的数据,它将为空。您可以显示您正在提出的请求吗?是
http://localhost:8001/currency-exchange/from/USD/to/INR
@sunny在调用
repository.findByFromAndTo(from,to)时向和从传递的值是什么?在调用之前添加一个log/sysout,并让我知道bothHello@sunny的值如果有帮助,您可以接受答案Hello@sunny,我很高兴它有帮助
http://localhost:8001/currency-exchange/from/usd/to/inr
http://localhost:8001/currency-exchange/from/USD/to/INR
 http://localhost:8001/currency-exchange/from/usd/to/inr
GET:    http://localhost:8001/currency-exchange/from/USD/to/INR