spring boot 修改Tomcat端口


package com.tsou.Controller;

import org.springframework.boot.*;
import org.springframework.boot.autoconfigure.*;

import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer;
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
import org.springframework.stereotype.*;
import org.springframework.web.bind.annotation.*;

@Controller
@EnableAutoConfiguration
public class SampleController implements EmbeddedServletContainerCustomizer {


    @RequestMapping("/")
    @ResponseBody
    String home() {
        return "Hello World! 你哈1你好 ";
    }

    public static void main(String[] args) {
        SpringApplication.run(SampleController.class, args);
    }
    @Override
    public void customize(ConfigurableEmbeddedServletContainer configurableEmbeddedServletContainer) {
        configurableEmbeddedServletContainer.setPort(8003);
    }

}

修改為:8003

或者修改配置文件端口:server.port=8003


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM