BAEL-2988 Move the code from spring-rest-simple to spring-mvc-simple-… (#7914)
* BAEL-2988 Move the code from spring-rest-simple to spring-mvc-simple-2, based on the review feedback. * BAEL-2988 revert previous changes in the spring-rest-simple
This commit is contained in:
parent
5e6304f837
commit
a0cbfa3b06
|
@ -0,0 +1,22 @@
|
|||
package com.baeldung.spring.config;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.format.FormatterRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
import com.baeldung.spring.config.converter.StringToEnumConverter;
|
||||
|
||||
@Configuration
|
||||
@EnableWebMvc
|
||||
public class MvcConfig implements WebMvcConfigurer {
|
||||
|
||||
public MvcConfig() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addFormatters(FormatterRegistry registry) {
|
||||
registry.addConverter(new StringToEnumConverter());
|
||||
}
|
||||
}
|
|
@ -1,9 +1,9 @@
|
|||
package com.baeldung.config.converter;
|
||||
package com.baeldung.spring.config.converter;
|
||||
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.baeldung.model.Modes;
|
||||
import com.baeldung.spring.model.Modes;
|
||||
|
||||
@Component
|
||||
public class StringToEnumConverter implements Converter<String, Modes> {
|
|
@ -1,15 +1,13 @@
|
|||
package com.baeldung.cors;
|
||||
package com.baeldung.spring.enums;
|
||||
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.baeldung.model.Modes;
|
||||
import com.baeldung.spring.model.Modes;
|
||||
|
||||
@CrossOrigin(maxAge = 3600)
|
||||
@RestController
|
||||
@RequestMapping("/enums")
|
||||
public class EnumController {
|
|
@ -1,4 +1,4 @@
|
|||
package com.baeldung.exceptions;
|
||||
package com.baeldung.spring.exceptions;
|
||||
|
||||
import org.springframework.core.convert.ConversionFailedException;
|
||||
import org.springframework.http.HttpStatus;
|
|
@ -1,4 +1,4 @@
|
|||
package com.baeldung.model;
|
||||
package com.baeldung.spring.model;
|
||||
|
||||
public enum Modes {
|
||||
ALPHA, BETA;
|
|
@ -2,7 +2,6 @@ package com.baeldung.config;
|
|||
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.format.FormatterRegistry;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.converter.HttpMessageConverter;
|
||||
import org.springframework.http.converter.StringHttpMessageConverter;
|
||||
|
@ -18,7 +17,6 @@ import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
|||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
import com.baeldung.config.converter.KryoHttpMessageConverter;
|
||||
import com.baeldung.config.converter.StringToEnumConverter;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.List;
|
||||
|
@ -73,9 +71,4 @@ public class MvcConfig implements WebMvcConfigurer {
|
|||
public void addCorsMappings(CorsRegistry registry) {
|
||||
registry.addMapping("/**");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addFormatters(FormatterRegistry registry) {
|
||||
registry.addConverter(new StringToEnumConverter());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue