Spring boot 如何在spring boot中从属性文件读取数组表示

Spring boot 如何在spring boot中从属性文件读取数组表示,spring-boot,property-files,Spring Boot,Property Files,我想读取具有数组格式的属性文件 我有这个属性文件: students.student[0] = ABC students.student[0].marks[0] = 10 students.student[0].marks[1] = 20 students.student[0].marks[2] = 30 students.student[0].marks[3] = 40 students.student[0].marks[4] = 50 students.student[0].marks[5]

我想读取具有数组格式的属性文件

我有这个属性文件:

students.student[0] = ABC
students.student[0].marks[0] = 10
students.student[0].marks[1] = 20
students.student[0].marks[2] = 30
students.student[0].marks[3] = 40
students.student[0].marks[4] = 50
students.student[0].marks[5] = 60
students.student[0].marks[6] = 70

students.student[1] = XYZ
students.student[1].marks[0] = 10
students.student[1].marks[1] = 20
students.student[1].marks[2] = 30
students.student[1].marks[3] = 40
students.student[1].marks[4] = 50
students.student[1].marks[5] = 60
students.student[1].marks[6] = 70
我正在尝试按如下方式读取此属性文件:

@ConfigurationProperties("students")
@PropertySource("classpath:student.properties")
public class StudentProperties{
   List<Student> students = new ArryaList<Student>();
   public static class Student
   {
      String name;
      List<Marks> marks = new ArrayList<Marks>;
      public static class Marks
      {
         int marks;
          //getters and setters
      }     
      //getters and setters
   }
   //getters and setters
 }
@ConfigurationProperties(“学生”)
@PropertySource(“类路径:student.properties”)
公共班级学生财产{
列出学生=新的忠诚者();
公立静态班学生
{
字符串名;
列表标记=新的ArrayList;
公共静态类分数
{
整数标记;
//接球手和接球手
}     
//接球手和接球手
}
//接球手和接球手
}
但它并不是在设定价值。
如何做到这一点?

虽然在某种形式()中可能存在,但这将被视为滥用application.properties文件,该文件用于配置,而不是作为数据存储


我建议您将数据保存在一个文件中,并使用许多合适的库中的一个来解析它们,ex-

映射POJO的格式不正确,在
学生
课堂上只需使用
列表

@ConfigurationProperties(“学生”)
@PropertySource(“类路径:student.properties”)
公共班级学生财产{
List student=new arrylist();
公立静态班学生
{
字符串名;
列表标记=新的ArrayList();
//接球手和接球手
}
//接球手和接球手
}
@ConfigurationProperties("students")
@PropertySource("classpath:student.properties")
public class StudentProperties{
List<Student> student = new ArryaList<Student>();
   public static class Student
      {
         String name;
         List<Integer> marks = new ArrayList<Integer>();

        //getters and setters
     }
     //getters and setters
  }