2017-02-07 1 views
0

私は2つのクラスを持っていますContentです。 1つの局は、1つまたは複数のコンテンツを有することができる。したがって、StationインスタンスとContentインスタンスの間にはoneToMany関係があります。 jacksonを使用してアプリケーションにjsonファイルをロードしようとしています。ここで BeanCreationException:クラスパスのリソースで定義された 'entityManagerFactory'という名前のBeanを作成中にエラーが発生しました

は駅のクラスです:

@Entity 
@Data 
public class Station { 

    @Id 
    @GeneratedValue 
    Long stationId; 

    @OneToMany(mappedBy = "station") 
    List<Content> contents = new ArrayList<Content>(); 

    @Column 
    String name; 
    @Column 
    String address; 

    public Station(String name, String address) { 
     this.name = name; 
     this.address = address; 
    } 

    public Station() { 

    } 
} 

とコンテンツクラスがある:

@Entity 
@Data 
public class Content { 

    @Id 
    @GeneratedValue 
    Long id; 

    @Autowired 
    StationRepository stationRepo; 

    @ManyToOne 
    @JoinColumn(name = "stationId") 
    Station station; 

    @Column 
    String name; 
    @Column 
    String type; 
    @Column 
    String address; 
    @Column 
    int sizeInByte; 
    @Column 
    boolean active; 

    public Content(String name, String type, 
        String address, int sizeInByte, 
        boolean active,long stationId) { 
     this.name = name; 
     this.type = type; 
     this.address = address; 
     this.sizeInByte = sizeInByte; 
     this.station=stationRepo.findOne(stationId); 
     this.active = active; 
    } 

    public Content() { 
    } 

    public Content(long id) { 
     this.id = id; 
    } 


} 

残念ながら、私はデータベースにJSONファイルを読み込むしようとすると、次のエラーが表示されます

Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory 
+0

エラーは、jsonにはまったく関連していません。これは、休止状態の設定が間違っていると思います。 – Andremoniy

+0

どうすれば修正できますか? – Salman

+0

完全なスタックトレースを入れることができますか? –

答えて

0

なぜか分かりませんが、エラーは自己側から来ます:

@Autowired 
    StationRepository stationRepo; 

です。削除すると問題なく動作します。

関連する問題

 関連する問題