File tree Expand file tree Collapse file tree 4 files changed +10
-11
lines changed
spring-boot-movies-xml-api
java/com/stacktips/movies Expand file tree Collapse file tree 4 files changed +10
-11
lines changed Original file line number Diff line number Diff line change @@ -24,11 +24,10 @@ repositories {
2424dependencies {
2525 implementation ' org.springframework.boot:spring-boot-starter-web'
2626 implementation ' org.springframework.boot:spring-boot-starter-data-mongodb'
27- implementation ' com.fasterxml.jackson.dataformat:jackson-dataformat-xml'
28-
2927 compileOnly ' org.projectlombok:lombok'
3028 annotationProcessor ' org.projectlombok:lombok'
3129 testImplementation ' org.springframework.boot:spring-boot-starter-test'
30+ implementation ' com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.17.1'
3231}
3332
3433tasks. named(' test' ) {
Original file line number Diff line number Diff line change 55import com .stacktips .movies .models .Movies ;
66import com .stacktips .movies .services .MovieService ;
77import org .springframework .http .MediaType ;
8- import org .springframework .http .ResponseEntity ;
98import org .springframework .web .bind .annotation .*;
109
1110@ RestController
1211@ RequestMapping (value = "/api/1.0/movies" ,
13- consumes = { MediaType .APPLICATION_XML_VALUE } ,
14- produces = { MediaType .APPLICATION_XML_VALUE }
12+ produces = MediaType .APPLICATION_XML_VALUE ,
13+ consumes = MediaType .APPLICATION_XML_VALUE
1514)
1615public class MoviesController {
1716
@@ -22,9 +21,8 @@ public MoviesController(MovieService movieService) {
2221 }
2322
2423 @ GetMapping
25- public ResponseEntity <Movies > getMovies () {
26- Movies movies = new Movies (movieService .getMovies ());
27- return ResponseEntity .ok (movies );
24+ public Movies getMovies () {
25+ return new Movies (movieService .getMovies ());
2826 }
2927
3028 @ PostMapping
Original file line number Diff line number Diff line change 11package com .stacktips .movies .models ;
22
3- import com . fasterxml . jackson . dataformat . xml . annotation . JacksonXmlRootElement ;
3+ import lombok . AllArgsConstructor ;
44import lombok .Getter ;
5+ import lombok .NoArgsConstructor ;
56import lombok .Setter ;
67import org .springframework .data .annotation .Id ;
78import org .springframework .data .mongodb .core .mapping .Document ;
1011
1112@ Getter
1213@ Setter
13- @ JacksonXmlRootElement (localName = "Movie" )
1414@ Document (collection = "movie" )
15+ @ AllArgsConstructor
16+ @ NoArgsConstructor
1517public class Movie {
1618
1719 @ Id
Original file line number Diff line number Diff line change 1- spring.data.mongodb.uri =mongodb://localhost:27017/movies_xml ?locale =en
1+ spring.data.mongodb.uri =mongodb://localhost:27017/movies ?locale =en
22spring.data.mongodb.username =
33spring.data.mongodb.password =
44spring.data.mongodb.authentication-database =
You can’t perform that action at this time.
0 commit comments