Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java SpringBoot can';t解析yml格式_Java_Spring_Yaml - Fatal编程技术网

Java SpringBoot can';t解析yml格式

Java SpringBoot can';t解析yml格式,java,spring,yaml,Java,Spring,Yaml,以上是我的yml配置 以下是相应的配置类 map: data: - id: 0 points: - x: 0 y: 0 place: place_type: table place_id: 0 place: place_type: prop place_id: 1 @PropertySou

以上是我的yml配置 以下是相应的配置类

map:
  data:
    - id: 0
      points:
        - x: 0
          y: 0
          place:
            place_type: table
            place_id: 0
            place:
              place_type: prop
              place_id: 1
@PropertySource(值={“classpath:floor_plan.yml”},factory=YamlSourceFactory.class)
@配置属性(前缀=“映射”)
@组成部分
@吸气剂
@塞特
公共类FloorPlan实现了可序列化{
私有静态最终长SerialVersionId=7889511292813486341L;
私人名单数据;
@塞特
@吸气剂
公共静态最终类图实现了可序列化{
私有静态最终长serialVersionUID=8165584398823841393L;
私有int-id;
私人名单点;
}
@塞特
@吸气剂
公共静态最终类点实现了可序列化{
私有静态最终长serialVersionUID=-3447034248118033017L;
私人INTX;
私营企业;
私募基金;
}
@塞特
@吸气剂
公共静态最终类PlaceItem实现可序列化{
私有静态最终长serialVersionUID=-820004850444500019L;
私有字符串类型;
私人身份证;
私募基金;
}
}
PlaceItem是一个递归引用类 无法将自动配置注入PlaceItem中的place属性 我的配置有问题吗?还是不能做到?
有什么方法可以进行此配置吗?

我没有使用
@PropertySource
测试您的代码,因为我不知道
YamlSourceFactory
是什么,它工作正常。感谢您对此问题的关注。抱歉,我没有解释YamlSourceFactory的角色,它用于加载yml源代码。我已经就这个问题向SpringBoot团队提供了反馈。他们真的不支持这种数据注入,如果你有兴趣,你可以看看,最后,我用一种不完美的方式解决了我的问题。
@PropertySource(value = {"classpath:floor_plan.yml"}, factory = YamlSourceFactory.class)
@ConfigurationProperties(prefix = "map")
@Component
@Getter
@Setter
public class FloorPlan implements Serializable {

    private static final long serialVersionUID = 7889511292813486341L;
    private List<Graph> data;

    @Setter
    @Getter
    public static final class Graph implements Serializable {
        private static final long serialVersionUID = 8165584398823841393L;
        private int id;
        private List<Point> points;
    }

    @Setter
    @Getter
    public static final class Point implements Serializable {
        private static final long serialVersionUID = -3447034248118033017L;
        private int x;
        private int y;
        private PlaceItem place;
    }

    @Setter
    @Getter
    public static final class PlaceItem implements Serializable {
        private static final long serialVersionUID = -8200048504444500019L;
        private String placeType;
        private int placeId;
        private PlaceItem place;
    }
}