Guest User

Untitled

a guest
Mar 15th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. <parent>
  2. <groupId>org.springframework.boot</groupId>
  3. <artifactId>spring-boot-starter-parent</artifactId>
  4. <version>1.5.4.RELEASE</version>
  5. <relativePath/> <!-- lookup parent from repository -->
  6. </parent>
  7. <dependencies>
  8. ....
  9. <dependency>
  10. <groupId>com.h2database</groupId>
  11. <artifactId>h2</artifactId>
  12. <scope>runtime</scope>
  13. </dependency>
  14. ....
  15. </dependencies>
  16.  
  17. spring:
  18. datasource:
  19. url: jdbc:h2:mem:my_db;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
  20. platform: h2
  21. username: sa
  22. password:
  23. driverClassName: org.h2.Driver
  24. jpa:
  25. database-platform: org.hibernate.dialect.H2Dialect
  26. hibernate:
  27. ddl-auto: create-drop
  28. properties:
  29. hibernate:
  30. show_sql: true
  31. use_sql_comments: true
  32. format_sql: true
  33. h2:
  34. console:
  35. enabled: true
  36. path: /console
  37. settings:
  38. trace: false
  39. web-allow-others: false
  40.  
  41. @Data
  42. @Entity
  43. @Table(
  44. name = "class_room"
  45. )
  46. @NoArgsConstructor
  47. public class Classroom
  48. {
  49.  
  50. private static final long serialVersionUID = 1L;
  51.  
  52. @Id
  53. @GeneratedValue
  54. private Long id;
  55.  
  56. @Column(nullable = false)
  57. @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)
  58. private ZonedDateTime dateCreated = ZonedDateTime.now();
  59.  
  60. @Column(nullable = false)
  61. @NotNull(message = "Classroom Name can not be null!")
  62. private String classroomName;
  63.  
  64. ....
  65.  
  66. }
  67.  
  68. mvn clean install spring-boot:run
  69.  
  70. insert into class_room (id, date_created, ... ) values (1, '2018-03-15 18:47:52.69', ... )
  71.  
  72. insert into class_room (id, date_created, ... ) values (1, now(), ... )
Add Comment
Please, Sign In to add comment