package service; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.vaadin.spring.annotation.EnableVaadin; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.context.web.SpringBootServletInitializer; import org.springframework.cloud.netflix.feign.EnableFeignClients; import org.springframework.cloud.netflix.zuul.EnableZuulProxy; import org.springframework.context.annotation.Bean; import org.springframework.hateoas.hal.Jackson2HalModule; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.servlet.config.annotation.EnableWebMvc; import javax.servlet.http.HttpServletResponse; import java.io.IOException; @SpringBootApplication @EnableFeignClients(basePackages = "service.clients") @EnableWebMvc @EnableAutoConfiguration @EnableZuulProxy @EnableVaadin @Controller public class Application extends SpringBootServletInitializer { public static void main(String[] args) { SpringApplication.run(Application.class, args); } @Bean public MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter() { MappingJackson2HttpMessageConverter jsonConverter = new MappingJackson2HttpMessageConverter(); jsonConverter.setSupportedMediaTypes(MediaType.parseMediaTypes("application/hal+json")); ObjectMapper objectMapper = new ObjectMapper(); objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); objectMapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true); objectMapper.registerModule(new Jackson2HalModule()); jsonConverter.setObjectMapper(objectMapper); return jsonConverter; } @RequestMapping("/") public ResponseEntity home(HttpServletResponse response) throws IOException { response.sendRedirect("/movies"); return new ResponseEntity(HttpStatus.PERMANENT_REDIRECT); } }