标签:图片 cal HERE XML generated res integer one log
JPA是Java Persistence API的简称,中文名Java持久层API,是JDK 5.0注解或XML描述对象-关系表的映射关系,并将运行期的实体对象持久化到数据库中。
spring:
datasource:
url: jdbc:mysql://localhost:3306/library?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=UTC
#library为数据库名
username: root
password: 123456
driver-class-name: com.mysql.cj.jdbc.Driver
jpa:
show-sql: true
properties:
hibernate:
format_sql: true
server:
port: 8181
@Entity
@Data
public class Book {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)//自增
private Integer id;
private String author;
private String name;
}
public interface BookRepo extends JpaRepository<Book,Integer> {
}
@RestController
@RequestMapping("/book")
public class BookHandle {
@Autowired
private BookRepo bookRepository;
@GetMapping("/findAll")
public List<Book> findAll(){
return bookRepository.findAll();
}
}
标签:图片 cal HERE XML generated res integer one log
原文地址:https://www.cnblogs.com/Wangddongyu235/p/13128618.html