| Line 108: |
Line 108: |
| | *Develop server reloading on changes (pom.xml changes are not detected) | | *Develop server reloading on changes (pom.xml changes are not detected) |
| | | | |
| − | == Example: Spring Boot with Data JPA and in memory database H2 == | + | ==Example: Spring Boot with Data JPA and in memory database H2== |
| | | | |
| − | === /pom.xml === | + | ===/pom.xml=== |
| | <syntaxhighlight lang="xml"> | | <syntaxhighlight lang="xml"> |
| | .... | | .... |
| Line 143: |
Line 143: |
| | </syntaxhighlight> | | </syntaxhighlight> |
| | | | |
| − | === /src/main/resources/application.properties === | + | ===/src/main/resources/application.properties=== |
| | <syntaxhighlight lang="java"> | | <syntaxhighlight lang="java"> |
| | spring.datasource.url=jdbc:h2:mem:testdb | | spring.datasource.url=jdbc:h2:mem:testdb |
| Line 151: |
Line 151: |
| | </syntaxhighlight>database will be accessible via http://localhost:8080/h2-console | | </syntaxhighlight>database will be accessible via http://localhost:8080/h2-console |
| | | | |
| − | === /src/main/java/com/in28minutes/learnspringboot/courses/bean/Course.java === | + | ===/src/main/java/com/in28minutes/learnspringboot/courses/bean/Course.java=== |
| | <syntaxhighlight lang="java"> | | <syntaxhighlight lang="java"> |
| | package com.in28minutes.learnspringboot.courses.bean; | | package com.in28minutes.learnspringboot.courses.bean; |
| Line 170: |
Line 170: |
| | private String name; | | private String name; |
| | private String author; | | private String author; |
| | + | |
| | + | public Course(){} // Entities must have a default constructor |
| | | | |
| | public Course(long id, String name, String author){ | | public Course(long id, String name, String author){ |
| Line 194: |
Line 196: |
| | </syntaxhighlight> | | </syntaxhighlight> |
| | | | |
| − | === src/main/resources/data.sql === | + | ===src/main/resources/data.sql=== |
| | querys in this file will be executed at startup automatically<syntaxhighlight lang="sql"> | | querys in this file will be executed at startup automatically<syntaxhighlight lang="sql"> |
| | insert into COURSE(ID, AUTHOR, NAME) | | insert into COURSE(ID, AUTHOR, NAME) |
| Line 204: |
Line 206: |
| | </syntaxhighlight> | | </syntaxhighlight> |
| | | | |
| − | === /src/main/java/com/in28minutes/learnspringboot/courses/repository/CourseRepository.java === | + | ===/src/main/java/com/in28minutes/learnspringboot/courses/repository/CourseRepository.java=== |
| | <syntaxhighlight lang="java"> | | <syntaxhighlight lang="java"> |
| | package com.in28minutes.learnspringboot.courses.repository; | | package com.in28minutes.learnspringboot.courses.repository; |
| Line 215: |
Line 217: |
| | ---- | | ---- |
| | | | |
| − | === /src/main/java/com/in28minutes/learnspringboot/courses/controller/CourseController.java === | + | ===/src/main/java/com/in28minutes/learnspringboot/courses/controller/CourseController.java=== |
| | <syntaxhighlight lang="java"> | | <syntaxhighlight lang="java"> |
| | package com.in28minutes.learnspringboot.courses.controller; | | package com.in28minutes.learnspringboot.courses.controller; |