我该如何解决 spring boot 中的这个错误?
我正在尝试获取端口号和主机名,但我不断收到此错误。
@SpringBootApplication
public class RegistrationFormApplication implements ApplicationListener<EmbeddedServletContainerInitializedEvent> {
@Autowired
Environment environment;
public static void main(String[] args) {
SpringApplication.run(RegistrationFormApplication.class, args);
}
Logger logger;
@Override
public void onApplicationEvent(EmbeddedServletContainerInitializedEvent embeddedServletContainerInitializedEvent) {
logger.info("Port " + embeddedServletContainerInitializedEvent.getApplicationContext().getEmbeddedServletContainer().getPort());
try {
logger.info("HOST Address " + InetAddress.getLocalHost().getHostAddress());
logger.info("Host Name " + InetAddress.getLocalHost().getHostName());
} catch (UnknownHostException e) {
}
}
}
MMMHUHU
相关分类