Reputation: 155
Hello i have a micronaut application with this application.yml
micronaut:
application:
name: hello-world
pref:
msg: Luca
inside a class i want to set the value of a variable :
@Value("${pref.msg}")
private lateinit var text : String
but the IDE complains saying that annotation argument must be a compile time constants
i also tried with
@Property(name = "pref.msg" )
but it compiles but do not read the property.
Anyone could help?
Upvotes: 1
Views: 3673
Reputation: 1678
You need to escape $
char using a backslash, because dollar is used by kotlin for template espressions.
@Value("\${pref.msg}")
Upvotes: 7