无法将yahoofinance导入我的代码

时间:2017-09-22 21:33:43

标签: java maven yahoo-finance

它一直显示红色标志,表示未导入。我检查了我的pom.xml:所有依赖项都存在。我还能尝试什么?

下面是代码和pom.xml文件:

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import yahoofinance.Stock;        //also not importing
import yahoofinance.YahooFinance;  // this line is not importing

import java.io.IOException;
import java.util.List;
import java.util.stream.Collectors;

@RestController
@RequestMapping("/rest/stock")
public class StockResource {

    @Autowired
    RestTemplate restTemplate;

    @GetMapping("/{username}")
    public List<Stock> getStock(@PathVariable("username") 
final String userName) {
        ResponseEntity<List<String>> quoteResponse = restTemplate.exchange("http://localhost:8300/rest/db/" + userName, HttpMethod.GET,
                null, new ParameterizedTypeReference<List<String>>() {
                });
        List<String> quotes = quoteResponse.getBody();
        return quotes
                .stream()
                .map(this::getStockPrice)
                .collect(Collectors.toList());
    }
`
    private Stock getStockPrice(String quote) {
        try {
            return YahooFinance.get(quote);
        } catch (IOException e) {
            e.printStackTrace();
            return new Stock(quote);
        }
    }
}

代码有什么问题吗?

0 个答案:

没有答案