outdated port injection in code
FyiurAmron opened this issue · comments
at
@Value(value="${local.server.port}")
as the way to inject port.
However, the guide at https://spring.io/guides/gs/testing-web/ mentions @LocalServerPort
:
Note the use of webEnvironment=RANDOM_PORT to start the server with a random port (useful to avoid conflicts in test environments) and the injection of the port with
@LocalServerPort
.
I fixed this in 3282679
@Buzzardo frankly, unless I'm missing something obvious, you actually broke it, and not fixed it? Prior to your commit, it had @LocalServerPort
previously, which was valid and worked, matched the text docs, and was supported at that time and is supported by SB 3.x, see https://docs.spring.io/spring-boot/docs/current-SNAPSHOT/api/org/springframework/boot/test/web/server/LocalServerPort.html - you changed it to @Value(value="${local.server.port}")
, which 1. is not the officially suggested way to handle it (@LocalServerPort
was added in 2.7 precisely to address the possible problems with @Value
injection), 2. doesn't match the current text docs, which properly state that @LocalServerPort
is the way to go.
OK. I put it back to @LocalServerPort in fe8cdd5
BTW, I now see how this mixup happened; previously it was
import org.springframework.boot.web.server.LocalServerPort;
, and now it's
import org.springframework.boot.test.web.server.LocalServerPort;
, due to spring-projects/spring-boot#29589 ... kinda funny how those things go :}