解决springboot中kotlin语法$失效的问题

@Value("${'$'}{aa.bb}")

lateinit var  ddd:String


如上,当用kotlin语法时由于$已有特殊用法,因此springboot中要用$必须通过 ${'$'} 获得。


另外,在kotlin中,如果要使得注解内容可以进行配置,而不是硬编码,可以使用#特殊字符,举个栗子:

 @Autowired
 lateinit var configPropertise: ConfigPropertise
 @Scheduled(fixedRateString = "#{configPropertise.period}") // 0/10 * * ? * *
 fun hpmDataSync() {}

如果是java,可以用$字符,举个栗子:

 @Value("${period}")
 public  int period;
 @Scheduled(fixedRateString = "${period}")
 private void getVehicleJob() {}

猜你喜欢

转载自blog.csdn.net/huweijian5/article/details/78287772