this is probably stupid, but I am not sure how to ...
# getting-started
t
this is probably stupid, but I am not sure how to find an answer. in spring, there is a file defining:
Copy code
fun MockMvc.get(urlTemplate: String, vararg vars: Any?, dsl: MockHttpServletRequestDsl.() -> Unit = {})
I defined my own version
Copy code
fun MockMvc.get(urlTemplate: String, vararg vars: Any?, subject: Subject = WithMockUser.defaultUser, dsl: MockHttpServletRequestDsl.() -> Unit = {})
in a test, by mistake, I imported both extension function, but when doing
mockMvc.get("/uri")
the first one got called. I am curious, how is the order defined in this case? I thought it could be the order of imports, but I tried both combination and the result did not change:
Copy code
import org.springframework.test.web.servlet.get
import my.own.get
or
Copy code
import my.own.get
import org.springframework.test.web.servlet.get
made no difference
c
Not sure what the order is, but a solution is to use import aliases (
import ... as ...
)
j
Import order doesn't have an impact on this. Resolution is done only based on the signature. In your case, most likely the one with less parameters is chosen.
t
I thought about the shorter signature, just could not find confirmation.
and yes, I am using
as
, but in this case I imported the wrong extension and did not realize it