重庆分公司,新征程启航

为企业提供网站建设、域名注册、服务器等服务

SpringBootTomcat启动实例代码详解

废话不多了,具体内容如下所示:

在洪泽等地区,都构建了全面的区域性战略布局,加强发展的系统性、市场前瞻性、产品创新能力,以专注、极致的服务理念,为客户提供网站设计、做网站 网站设计制作按需求定制网站,公司网站建设,企业网站建设,成都品牌网站建设,全网营销推广,成都外贸网站建设,洪泽网站建设费用合理。

Application configuration class:
@SpringBootApplication
public class ServletInitializer extends SpringBootServletInitializer {
  @Override
  protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
    return application.sources(ServletInitializer.class);
  }
  public static void main(String[] args) throws Exception {
    SpringApplication.run(ServletInitializer.class, args);
  }
}

注意: 启动类放在项目的包的最外层最好,这样可以扫描到所有的包路径。

controller:

@Controller
public class BootController {
  @RequestMapping("/")
  @ResponseBody
  String home() {
    return "Hello World!";
  }
  public static void main(String[] args) throws Exception {
    SpringApplication.run(BootController.class, args);
  }
}

pom


  4.0.0
  cn.creditease.springboot
  springboot
  war
  1.0
  Maven Webapp
  http://maven.apache.org
  
  UTF-8
  UTF-8
  1.7
  1.7
  7.0.67
  
  
    org.springframework.boot
    spring-boot-starter-parent
    1.4.1.RELEASE
  
  
    
      org.springframework.boot
      spring-boot-starter-web
    
    
      org.springframework.boot
      spring-boot-starter-tomcat
      provided
    
    
      org.springframework.boot
      spring-boot-starter-test
      test
    
  
  
      
        spring-releases
        Spring Releases
        http://repo.spring.io/libs-release-local
        
          true
        
      
  

注意:如果想用tomcat7启动要制定你的tomcat版本号。

server:
 port: 8080
 spring.mvc.view.prefix: /WEB-INF/jsp/
 spring.mvc.view.suffix: .jsp

项目

SpringBoot Tomcat启动实例代码详解

总结

以上所述是小编给大家介绍的SpringBoot Tomcat启动实例代码详解,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对创新互联网站的支持!


文章题目:SpringBootTomcat启动实例代码详解
分享路径:http://cqcxhl.cn/article/jggcjg.html

其他资讯

在线咨询
服务热线
服务热线:028-86922220
TOP