ExchangeValue exchangeValue = repository.findByFromAndTo(from, to);
尽管h2 db中存在数据,但exchangeValue仍为空
我的代码网址是https://github.com/sunny107842/currency-exchange
package com.sunny.microservices.currencyexchangeservice;
import org.springframework.data.jpa.repository.JpaRepository;
public interface ExchangeValueRepository extends
JpaRepository<ExchangeValue, Long>{
ExchangeValue findByFromAndTo(String from, String to);
}
编辑 完整代码可以在github url
上找到交换类
`
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;
}
}
有人可以帮我吗?数据存在于数据库中
我正在打这个电话以获取数据
http://localhost:8001/currency-exchange/from/usd/to/inr
请让我知道是否需要其他数据。
答案 0 :(得分:1)
这很简单。在data.sql中,您使用大写字母插入了值。尝试使用http://localhost:8001/currency-exchange/from/USD/to/INR
或在data.sql中将其更改为小写。
答案 1 :(得分:0)
Hi Issue在其余呼叫中。这是区分大小写的错误
正确的呼叫应该是
http://localhost:8001/currency-exchange/from/USD/to/INR
代替
http://localhost:8001/currency-exchange/from/usd/to/inr
答案 2 :(得分:0)
这是区分大小写的问题: 将usd更改为USD,将ind更改为INR
致电
GET: http://localhost:8001/currency-exchange/from/USD/to/INR