# HG changeset patch # User Dirk Olmes # Date 1597328300 -7200 # Node ID d57d0c6a841b74690883ff612a137c2312df8a12 # Parent 227f3105fedd6f4224afd473a062c8a88069ad83 Einbau von liquibase zum Erzeugen des Schemas diff -r 227f3105fedd -r d57d0c6a841b spring-boot-playground/pom.xml --- a/spring-boot-playground/pom.xml Thu Aug 13 15:58:57 2020 +0200 +++ b/spring-boot-playground/pom.xml Thu Aug 13 16:18:20 2020 +0200 @@ -46,6 +46,10 @@ org.springframework.boot spring-boot-starter-data-jpa + + org.liquibase + liquibase-core + com.h2database h2 diff -r 227f3105fedd -r d57d0c6a841b spring-boot-playground/src/main/java/de/comline/spring/controller/MovieController.java --- a/spring-boot-playground/src/main/java/de/comline/spring/controller/MovieController.java Thu Aug 13 15:58:57 2020 +0200 +++ b/spring-boot-playground/src/main/java/de/comline/spring/controller/MovieController.java Thu Aug 13 16:18:20 2020 +0200 @@ -1,6 +1,7 @@ package de.comline.spring.controller; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RestController; @@ -12,8 +13,13 @@ @Autowired private MovieService service; + @GetMapping("/movies") + public String getMovies() { + return service.listAllMovies(); + } + @PostMapping("/movie/{title}") - public String index(@PathVariable(name = "title") String title) { + public String createMovie(@PathVariable(name = "title") String title) { service.createMovie(title); return "Successfully created movie " + title + ".\n"; } diff -r 227f3105fedd -r d57d0c6a841b spring-boot-playground/src/main/java/de/comline/spring/service/MovieService.java --- a/spring-boot-playground/src/main/java/de/comline/spring/service/MovieService.java Thu Aug 13 15:58:57 2020 +0200 +++ b/spring-boot-playground/src/main/java/de/comline/spring/service/MovieService.java Thu Aug 13 16:18:20 2020 +0200 @@ -19,4 +19,11 @@ movie = repository.save(movie); return movie; } + + @Transactional + public String listAllMovies() { + StringBuilder buf = new StringBuilder(128); + repository.findAll().forEach(movie -> buf.append(movie.getTitle()).append(",")); + return buf.toString(); + } } diff -r 227f3105fedd -r d57d0c6a841b spring-boot-playground/src/main/resources/application.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/spring-boot-playground/src/main/resources/application.properties Thu Aug 13 16:18:20 2020 +0200 @@ -0,0 +1,3 @@ +spring.datasource.url = jdbc:h2:~/unittest;AUTO_SERVER=true + +spring.liquibase.changelog = classpath:liquibase/changelog.xml diff -r 227f3105fedd -r d57d0c6a841b spring-boot-playground/src/main/resources/liquibase/changelog.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/spring-boot-playground/src/main/resources/liquibase/changelog.xml Thu Aug 13 16:18:20 2020 +0200 @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + +