我正在启动一个Spring Boot应用程序mvn spring-boot:run.
我@Controller的一个需要有关应用程序正在侦听的主机和端口的信息,即localhost:8080(或127.x.y.z:8080).在Spring Boot文档之后,我使用了server.address和server.port属性:
@Controller
public class MyController {
@Value("${server.address}")
private String serverAddress;
@Value("${server.port}")
private String serverPort;
//...
}
在启动应用程序时mvn spring-boot:run,我得到以下异常:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'myController': Injection of autowired dependencies failed; nested exception is
org.springframework.beans.factory.BeanCreationException: Could not autowire field: ... String ... serverAddress; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'server.address' in string value "${server.address}"
双方server.address并server.port不能自动装配.
如何找到Spring Boot应用程序绑定的(本地)主机/地址/ NIC和端口?
最后
以上就是欣慰砖头最近收集整理的关于服务器控制端口获取信息,如何在Spring Boot中获取本地服务器主机和端口?的全部内容,更多相关服务器控制端口获取信息,如何在Spring内容请搜索靠谱客的其他文章。
发表评论 取消回复