1.首先进行application.yml 的配置
spring:
datasource:
type: com.zaxxer.hikari.HikariDataSource
url: jdbc:mysql://localhost/test?serverTimezone=UTC&characterEncoding=utf-8
username: root
driver-class-name: com.mysql.cj.jdbc.Driver
hikari:
minimum-idle: 3
idle-timeout: 100000
jpa:
show-sql: true
hibernate:
ddl-auto: update
2.对domin的类进行配置
@Entity(name = "countries")
/*配置json,注意设立自增长后需要单独加入注解
@GeneratedValue(strategy=GenerationType.AUTO)*/
@JsonIgnoreProperties(value = {"hibernateLazyInitializer","handler"})
public class Countries {
@Id
@Column(name = "country_id")
private Integer countryId;
@Column(name = "country_name")
private String countryName;
@Column(name = "region_id")
private Integer regionId;
3.对Mapper进行配置
@Repository
public interface CountryDao extends JpaRepository<Countries,Integer> {
}
//分页
@Repository
public interface MerchantsDao extends PagingAndSortingRepository<Merchants,Integer> {
Page<Merchants> findByMerchantsName(String name, Pageable pageable);
}
网友评论