Map<String, CoordinateDto> map = new HashMap<>(); @PostConstruct private Map <String, CoordinateDto> generatorCoordinate() throws Exception { log.info("读取结算单填充坐标点 xy.csv"); Resource resource = new ClassPathResource("xy.csv"); InputStream inputStream = resource.getInputStream(); CsvReader csvReader = new CsvReader(inputStream, Charset.forName("utf-8")); csvReader.readHeaders(); //跳过第一行标题行 while (csvReader.readRecord()) { String row = csvReader.getRawRecord(); //读取一整行数据 String[] arr = row.split(","); map.put(arr[0], new CoordinateDto(Integer.parseInt(arr[1]), Integer.parseInt(arr[2]))); } return map; }