spring-boot启动初探

Spring Boot充分利用了JavaConfig的配置模式以及“约定优于配置”的理念,能够极大的简化基于Spring MVC的Web应用和REST服务开发。

使用spring boot开发web应用,决定项目是否可以直接启动的是spring-boot-starter-tomcat模块,我们可以直接引入spring-boot-starter-web


    org.springframework.boot
    spring-boot-starter-web

此模块中内嵌了tomcat模块。
@SpringBootApplication 启动类启动,默认端口为8080。

@SpringBootApplication
public class DemoApplication implements EmbeddedServletContainerCustomizer{

    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }

    @Override
    public void customize(ConfigurableEmbeddedServletContainer container) {
        // TODO Auto-generated method stub
        container.setPort(8001);
    }
}

实现EmbeddedServletContainerCustomizer接口类,可改端口

你可能感兴趣的:(springboot)