第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

使用 jfree 圖表從 mysql 數(shù)據(jù)庫生成餅圖時出錯

使用 jfree 圖表從 mysql 數(shù)據(jù)庫生成餅圖時出錯

qq_笑_17 2022-06-04 09:26:57
我想使用 jfree 圖表和來自 mysql 數(shù)據(jù)庫的數(shù)據(jù)創(chuàng)建一個餅圖,但我似乎遇到了錯誤。這是我的代碼。我有一個 LocationRepository 我在其中實現(xiàn)我的 sql 查詢   public interface LocationRepository extends JpaRepository<Location, Integer> {       //hibernate query language (jpql)       @Query("select type,count(type) from location group by type")       public List<Object[]> findTypeAndTypeCout();      }我也有我的 ReportUtility 接口,如下所示   public interface ReportUtil {      void generatePieChart(String path, List<Object[]> data);      }這是我的 ReportUtility 實現(xiàn)類  @Component  public class ReportUtilImpl implements ReportUtil {    @Override    public void generatePieChart(String path, List<Object[]> data) {    // TODO Auto-generated method stub    DefaultPieDataset dataset = new DefaultPieDataset();    for (Object[] objects : data) {        dataset.setValue(objects[0].toString(), new Double(objects[1].toString()));    }    JFreeChart chart = ChartFactory.createPieChart3D("Location Type Report", dataset);    try {        ChartUtilities.saveChartAsJPEG(new File(path+"/pieChart.jpeg"), chart, 300, 300);    } catch (IOException e) {        e.printStackTrace();    }  }}最后是控制器   @Controller    public class LocationController {  @Autowired  LocationService service;  @Autowired  LocationRepository repository;  @Autowired  ReportUtil reportUtil;  @Autowired  ServletContext sc;  @RequestMapping("/generateReport")   public String generateReport() {     String path = sc.getRealPath("/");     List<Object[]> data = repository.findTypeAndTypeCout();     reportUtil.generatePieChart(path, data);     return "report";        }     }
查看完整描述

1 回答

?
慕少森

TA貢獻(xiàn)2019條經(jīng)驗 獲得超9個贊

從錯誤中,LocationRepository無法創(chuàng)建 bean。LocationRepositorySpring IOC 無法使用您的代碼。用 注釋您的存儲庫@Repository,以便 spring 創(chuàng)建 bean。

根據(jù)評論更新答案:

從堆棧跟蹤QuerySyntaxException: location is not mapped中,Location沒有創(chuàng)建實體。所以,要么創(chuàng)建它,要么使用@Query(nativeQuery=true)


查看完整回答
反對 回復(fù) 2022-06-04
  • 1 回答
  • 0 關(guān)注
  • 79 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號