Order of evaluation in Spring bean definition dsl for kotlin?

188 Views Asked by At

I wonder when environment method is being taken into account.

Considering following code:

bean { Bar(ref()) } // requires bean of type Foo
environment(
    { !activeProfiles.contains("local") },
    { ProdFoo() }))
environment(
    { activeProfiles.contains("local") },
    { bean<LocalFoo>() })

Sometimes I observed errors related with no bean of type Foo. Does it mean that environment is not evaluated as one of the first expressions?

1

There are 1 best solutions below

0
On BEST ANSWER

The answer is plain simple - I've forgot to wrap ProdFoo() into bean{ ... }