1.开发工具:Tomcat8+Oralce11+Eclipse-EE
2.项目工程图:
3.图书表:
图书属性:id 书名 作者 出版社 出版年份 简介 类别
建表语句:
create table book(
id number(10) primary key not null,
title varchar2(50) not null,
author varchar2(20) not null,
press varchar2(50) not null,
publicationYear varchar2(50) not null,
introduction varchar2(200) not null,
category varchar2(20) not null
);
4.关掉一些日志:logback.xml
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<!-- encoders are assigned the type
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<root level="INFO">
<appender-ref ref="STDOUT" />
</root>
</configuration>
5.实体类:Book.java
package ssh.domain;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
@Entity // 实体类将映射到数据表,不指定表名即为类名
public class Book {
@Id //定义为主键
@GeneratedValue //JPA通用策略生成器
private Long id;
private String title;
private String author;
private String press;
private String publicationYear;
private String introduction;
private String category;
public Book() {
}
public Book(Long id, String title, String author, String press, String publicationYear, String introduction,
String category) {
super();
this.id = id;
this.title = title;
this.author = author;
this.press = press;
this.publicationYear = publicationYear;
this.introduction = introduction;
this.category = category;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
public String getPress() {
return press;
}
public void setPress(String press) {
this.press = press;
}