Issue
I upgraded my app from spring boot 1.5.9.RELEASE to 2.0.0.RELEASE, and I can no longer import org.springframework.boot.context.embedded.LocalServerPort
. I was using this to inject the port the server is running on during a test:
public class Task1Test {
@LocalServerPort
private int port;
The Spring release notes do not mention this removal and @LocalServerPort was not deprecated.
Is there an equivalent in Spring Boot 2.0 that I can use?
Edit: I'm pretty sure that the class is gone. I'm getting these compilation errors:
[ERROR] ... Task1Test.java:[12,49]package org.springframework.boot.context.embedded does not exist
[ERROR] ... Task1Test.java:[46,6] cannot find symbol
symbol: class LocalServerPort
Solution
It looks like it was moved to org.springframework.boot.web.server.LocalServerPort without notice. Hope that helps.
Answered By - hd1
Answer Checked By - Gilberto Lyons (JavaFixing Admin)