美文网首页
Spring Boot Jpa

Spring Boot Jpa

作者: 风雨楼兰 | 来源:发表于2018-10-25 11:45 被阅读0次

    gradle配置

       compile("org.springframework.boot:spring-boot-starter-data-jpa")
    

    配置文件:

    spring:
    #  security:
    #    user:
    #      name: lb
    #      password: 123456
      datasource:
        driver-class-name: com.mysql.cj.jdbc.Driver
        url: jdbc:mysql://localhost:3306/db1?useUnicode=true&characterEncoding=utf8&autoReconnect=true&useSSL=false&serverTimezone=GMT
        username: root
        password: 123456
        hikari:
          max-lifetime: 600000
          maximum-pool-size: 20
          connection-timeout: 30000
      jpa:
        show-sql: true
        hibernate:
          naming:
            physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
    
    

    model定义:

    @Entity
    @Data
    public class User implements Serializable{
        @Id
        private Long userId;
    
        private String userName;
    
        protected User(){}
    }
    

    dao定义:

    public interface IUserDao extends Repository<User,Long> {
        List<User> queryAllByUserName(String name);
    }
    

    相关文章

      网友评论

          本文标题:Spring Boot Jpa

          本文链接:https://www.haomeiwen.com/subject/fnpqtqtx.html