我的任务是使用CDI
创建一个包含RESTful
服务的JavaEE应用程序。我将不得不从Oracle
数据库中获取数据。具有CDI的Java后端RESTful服务器应用程序
我在互联网上研究了如何做到这一点,但我找不到一个项目/指南,它正在使用我所需要的一切。我创建了一个实体类,但我无法弄清楚如何处理来自数据库的数据,只需要为数据库crud
。
我的实体类:
@Entity
@Table(name = "BOOKS")
public class Book implements Serializable {
private int id;
private String author;
private String title;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", unique = true, nullable = false)
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
@Column(name = "author", unique = true, nullable = false)
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author= author;
}
@Column(name = "title", unique = true, nullable = false)
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title= title;
}
}
任何帮助,或连结导游是非常赞赏。提前致谢!
有很多例子,例如http://www.concretepage.com/spring-boot/spring-boot-rest-jpa-hibernate-mysql-example –
为什么答案被低估? – Titulum
不要问我。感谢您的链接:) – Hevesi