Defining beans with conditionals

We can modify our application class to load the bean base on a value using SpEL:

package com.microservices.chapter2import org.springframework.beans.factory.annotation.Autowiredimport org.springframework.boot.autoconfigure.SpringBootApplicationimport org.springframework.boot.autoconfigure.condition.ConditionalOnExpressionimport org.springframework.boot.runApplicationimport org.springframework.context.annotation.Beanimport org.springframework.stereotype.Controllerimport org.springframework.web.bind.annotation.PathVariableimport org.springframework.web.bind.annotation.RequestMappingimport org.springframework.web.bind.annotation.RequestMethodimport org.springframework.web.bind.annotation.ResponseBody@SpringBootApplication ...

Get Hands-On Microservices with Kotlin now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.