spring-boot|spring-boot war包启动方式(发布到web容器的demo)

今天学习了springboot 发布war包到web容器,如tomcat jetty等的学习,做个备忘.


启动类:

package com.cowoby.springbootedu; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.web.support.SpringBootServletInitializer; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; /** * WAR包的启动方式 */ @SpringBootApplication public class SpringBootEduApplicationWar extends SpringBootServletInitializer{public static void main(String[] args) { SpringApplication.run(SpringBootEduApplicationWar.class, args); } @RestController public static class MyController{ @RequestMapping("/hello") @ResponseBody public String hello(){ System.out.println("hello spring boot..."); return "hello spring boot..."; } } }


【spring-boot|spring-boot war包启动方式(发布到web容器的demo)】


pom.xml

4.0.0com.cowoby spring-boot-edu 0.0.1-SNAPSHOT warspring-boot-edu Demo project for Spring Boot. 此配置是使用war包的启动方式 UTF-8 UTF-8 1.8 org.springframework.boot spring-boot-dependencies 1.5.6.RELEASE pom import org.springframework.boot spring-boot-starter org.springframework.boot spring-boot-starter-web org.springframework.boot spring-boot-starter-tomcat org.springframework.boot spring-boot-starter-tomcat provided org.springframework.boot spring-boot-starter-test test org.springframework.boot spring-boot-maven-plugin org.apache.maven.plugins maven-war-plugin false



    推荐阅读