0

I'm trying to add the following annotation to an endpoint:

@GetMapping(value = arrayOf("path/1", "path/2"))
fun myEndpoint() { ... }

The Kotlin compiler complains that value only accepts String and not Array<String> while the documentation of the annotation clearly states that value accepts String[]. Any idea how to fix this?

Kotlin Version 1.1.60, Spring 4.3.13

Christoph Grimmer
  • 4,210
  • 4
  • 40
  • 64

2 Answers2

1

Ok, after the correct answer was deleted for some reason I will repeat it:

@GetMapping("path/1", "path/2")
fun myEndpoint() { ... }

works. As @yole answered Kotlin: how to pass array to Java annotation "The value parameter is automatically converted to a vararg parameter in Kotlin, as described in http://kotlinlang.org/docs/reference/annotations.html#java-annotations."

Christoph Grimmer
  • 4,210
  • 4
  • 40
  • 64
0

Try this

@GetMapping(value = ["some thing", "another some thing"])

In my env works properly with Spring Beans and Controler Mapping.