如何把springboot jar项目 改为war项目

这篇文章主要介绍了如何把springboot jar项目 改为war项目,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下

这篇文章主要介绍了如何把springboot jar项目 改为war项目,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下

启动类JeewxBootApplication 添加继承SpringBootServletinitializer

重写实现

@SpringBootApplication public class JeewxBootApplication extends SpringBootServletinitializer { public final static Logger log = LoggerFactory.getLogger(JeewxBootApplication.class); public static void main(String[] args) { ConfigurableApplicationContext application = SpringApplication.run(JeewxBootApplication.class, args); Environment env = application.getEnvironment(); String ip = InetAddress.getLocalHost().getHostAddress(); String port = env.getProperty("server.port"); String path = env.getProperty("server.servlet.context-path"); log.info("n----------------------------------------------------------nt" + "Application is running! Access URLs:nt" + "Local: tthttp://localhost:" + port + path + "/nt" + "External: thttp://" + ip + ":" + port + path + "/nt" + "----------------------------------------------------------"); } @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { return application.sources(JeewxBootApplication.class); } }

pom文件添加插件

org.apache.maven.pluginsmaven-war-pluginfalse

pom文件添加依赖

org.springframework.bootspring-boot-starter-tomcatprovidedjavax.servletjavax.servlet-api3.0.1provided

相关文章

HashMap是Java中最常用的集合类框架,也是Java语言中非常典型...
在EffectiveJava中的第 36条中建议 用 EnumSet 替代位字段,...
介绍 注解是JDK1.5版本开始引入的一个特性,用于对代码进行说...
介绍 LinkedList同时实现了List接口和Deque接口,也就是说它...
介绍 TreeSet和TreeMap在Java里有着相同的实现,前者仅仅是对...
HashMap为什么线程不安全 put的不安全 由于多线程对HashMap进...