Created
July 14, 2015 15:58
-
-
Save cer/a4715375d903eaddb0b2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package net.chrisrichardson.microservices.restfulspringboot | |
import org.springframework.cloud.netflix.eureka.EnableEurekaClient | |
import org.springframework.context.annotation._ | |
import org.springframework.boot.autoconfigure.EnableAutoConfiguration | |
import net.chrisrichardson.microservices.restfulspringboot.backend.ScalaObjectMapper | |
import net.chrisrichardson.microservices.restfulspringboot.dustview.DustViewResolver | |
import org.springframework.web.client.{ResponseErrorHandler, RestTemplate} | |
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter | |
import scala.collection.JavaConversions._ | |
import org.springframework.http.client.ClientHttpResponse | |
@Configuration | |
@EnableAutoConfiguration | |
@ComponentScan | |
@Import(Array(classOf[EurekaClientConfiguration])) | |
class UserRegistrationConfiguration { | |
@Bean | |
@Primary | |
def scalaObjectMapper() = new ScalaObjectMapper | |
@Bean | |
def dustViewResolver = { | |
val resolver = new DustViewResolver | |
resolver.setPrefix("/WEB-INF/views/") | |
resolver.setSuffix(".dust") | |
resolver | |
} | |
class DummyClass {} | |
@Bean | |
@Profile(Array("!enableEureka")) | |
def restTemplate() = new RestTemplate() | |
@Bean | |
def restTemplateInitializer(restTemplate : RestTemplate) : DummyClass = { | |
restTemplate.getMessageConverters foreach { | |
case mc: MappingJackson2HttpMessageConverter => | |
mc.setObjectMapper(scalaObjectMapper()) | |
case _ => | |
} | |
new DummyClass() | |
} | |
} | |
@Configuration | |
@EnableEurekaClient | |
@Profile(Array("enableEureka")) | |
class EurekaClientConfiguration { | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment