方案一:

src/main/resuorces 文件夹下新建application.properties 文件 并添加内容server.port=8011即可

方案二:

使用EmbeddedServletContainerCustomizer代码如下:

package com.spring.boot;

import org.springframework.boot.context.embedded.*;
import org.springframework.stereotype.Component;

@Component
public class CustomizationBean implements EmbeddedServletContainerCustomizer {

@Override
public void customize(ConfigurableEmbeddedServletContainer container) {
container.setPort(9000);
}
}

相关文章:

  • 2021-11-28
  • 2021-05-31
  • 2021-04-24
  • 2021-10-31
  • 2021-10-16
  • 2021-09-01
猜你喜欢
  • 2021-04-11
  • 2021-11-23
  • 2021-12-31
  • 2021-11-23
  • 2021-11-23
  • 2021-11-28
相关资源
相似解决方案