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:
wugangca 2019-10-04 06:30:54 -06:00 committed by KevinGilmore
parent 5e6304f837
commit a0cbfa3b06
6 changed files with 28 additions and 15 deletions

View File

@ -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());
}
}

View File

@ -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> {

View File

@ -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 {

View File

@ -1,4 +1,4 @@
package com.baeldung.exceptions;
package com.baeldung.spring.exceptions;
import org.springframework.core.convert.ConversionFailedException;
import org.springframework.http.HttpStatus;

View File

@ -1,4 +1,4 @@
package com.baeldung.model;
package com.baeldung.spring.model;
public enum Modes {
ALPHA, BETA;

View File

@ -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());
}
}