Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <parent>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-parent</artifactId>
- <version>1.5.4.RELEASE</version>
- <relativePath/> <!-- lookup parent from repository -->
- </parent>
- <dependencies>
- ....
- <dependency>
- <groupId>com.h2database</groupId>
- <artifactId>h2</artifactId>
- <scope>runtime</scope>
- </dependency>
- ....
- </dependencies>
- spring:
- datasource:
- url: jdbc:h2:mem:my_db;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
- platform: h2
- username: sa
- password:
- driverClassName: org.h2.Driver
- jpa:
- database-platform: org.hibernate.dialect.H2Dialect
- hibernate:
- ddl-auto: create-drop
- properties:
- hibernate:
- show_sql: true
- use_sql_comments: true
- format_sql: true
- h2:
- console:
- enabled: true
- path: /console
- settings:
- trace: false
- web-allow-others: false
- @Data
- @Entity
- @Table(
- name = "class_room"
- )
- @NoArgsConstructor
- public class Classroom
- {
- private static final long serialVersionUID = 1L;
- @Id
- @GeneratedValue
- private Long id;
- @Column(nullable = false)
- @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)
- private ZonedDateTime dateCreated = ZonedDateTime.now();
- @Column(nullable = false)
- @NotNull(message = "Classroom Name can not be null!")
- private String classroomName;
- ....
- }
- mvn clean install spring-boot:run
- insert into class_room (id, date_created, ... ) values (1, '2018-03-15 18:47:52.69', ... )
- insert into class_room (id, date_created, ... ) values (1, now(), ... )
Add Comment
Please, Sign In to add comment