2016-11-08 6 views
0

私はエンティティを構築するためにSpringのデータ休憩を使用しようとしています。 はここ春のデータを設定するエンティティ

compile group: 'org.springframework.boot', name: 'spring-boot-starter-data-rest', version: '1.4.1.RELEASE' 
    compile group: 'org.springframework.boot', name: 'spring-boot-starter-data-jpa', version: '1.4.1.RELEASE' 
    compile group: 'com.h2database', name: 'h2', version: '1.4.193' 
    testCompile group: 'junit', name: 'junit', version: '4.11' 

ここで他、

@Entity 
public class Message extends BaseEntity{ 

    private String senderId; 
    private String receiverId; 
    private String mediaId; 
    @ManyToOne 
    private User user; 

    protected Message(){ 
     super(); 
    } 

    public Message(String senderId, String receiverId, String mediaId) { 
     this(); 
     this.senderId = senderId; 
     this.receiverId = receiverId; 
     this.mediaId = mediaId; 
    } 
} 

これらはこれをm

public interface UserRepository extends CrudRepository<User, Long> { 
} 

public interface MessageRepository extends CrudRepository<Message, Long>{ 

} 

、私のリポジトリです

@Entity 
public class User extends BaseEntity{ 
    private String yguid; 
    private String name; 
    private String email; 
    @OneToMany(mappedBy = "user", cascade = CascadeType.ALL) 
    private List<Message> messages; 

    protected User(){ 
     super(); 
     messages = new ArrayList<>(); 
    } 

    public User(String yguid, String name, String email) { 
     this(); 
     this.yguid = yguid; 
     this.name = name; 
     this.email = email; 
    } 
} 

、エンティティの私の定義ですが、私の依存関係ですyエントリーポイント。私は、サーバーをスピンアップし、ローカルホストに行く

@SpringBootApplication 
public class App { 
    public static void main(String[] args) { 
     SpringApplication.run(App.class, args); 
    } 
} 

:8080/ これは私が得るすべてである、

{ 
_links: { 
profile: { 
href: "http://localhost:8080/profile" 
} 
} 
} 

私は春のチュートリアルに従って、あまりにも実体を見て期待してい。私はここで間違って何をしていますか?

+0

あなたのクラスパスにdata.sqlを入れていくつかのデータを挿入し、 – shazin

答えて

1

あなたのリポジトリに@RepositoryRestResourceと注釈を付けることを試みましたか?これは間違いなく機能するはずです。

関連する問題