网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

SpringBoot中war包如何部署到Tomcat服务器

这篇文章主要介绍SpringBoot中war包如何部署到Tomcat服务器,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!

成都创新互联公司专业为企业提供化隆网站建设、化隆做网站、化隆网站设计、化隆网站制作等企业网站建设、网页设计与制作、化隆企业网站模板建站服务,十余年化隆做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。

(1)pom.xml文件修改war,默认是jar包,节点中增加springboot,即生成war包的名字,完整pom.xml文件内容如下:



  4.0.0

  springboot
  springboot
  0.0.1-SNAPSHOT
  war

  springboot
  Demo project for Spring Boot

  
    org.springframework.boot
    spring-boot-starter-parent
    1.5.4.RELEASE
     
  

  
    UTF-8
    UTF-8
    1.7
  

  
    
      org.springframework.boot
      spring-boot-starter
      
        
          org.springframework.boot
          spring-boot-starter-logging
        
      
    
    
      org.springframework.boot
      spring-boot-starter-web
    
    
      org.springframework.boot
      spring-boot-starter-test
      test
    
    
      org.springframework.boot
      spring-boot-starter-thymeleaf
    
    
      org.springframework.boot
      spring-boot-starter-log4j
      1.3.8.RELEASE
    
    
      org.springframework.boot
      spring-boot-starter-data-redis
    
    
      MySQL
      mysql-connector-java
    
    
      org.mybatis.spring.boot
      mybatis-spring-boot-starter
      1.1.1
    
  

  
    springboot
    
      
        org.springframework.boot
        spring-boot-maven-plugin
      
    
  

(2)修改项目启动类,继承SpringBootServletInitializer,如下:

package springboot;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.scheduling.annotation.EnableScheduling;

@SpringBootApplication
@EnableScheduling
@EnableCaching
public class SpringbootApplication extends SpringBootServletInitializer{

  public static void main(String[] args) {
    SpringApplication.run(SpringbootApplication.class, args);
  }
  @Override
  protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
    return application.sources(SpringbootApplication.class);
  }
}

(3)打包:可以通过eclipse run as ->maven install,也可以进入项目的根目录,也就是pom.xml同一级目录,启动cmd控制台,执行mvn install package,如下:

SpringBoot中war包如何部署到Tomcat服务器

(4)环境搭建(linux环境JDK安装与Tomacat安装(springboot支持tomcat7以上))

JDK安装参考:https://www.jb51.net/LINUXjishu/66536.html

Tomcat安装参考:https://www.jb51.net/article/95272.htm

(5)将打包好的war包上传至tomcat目录下webapp目录下,启动tomcat服务器。

(6)访问项目路径:http://ip地址:端口号/项目打包名称/方法名(项目打包名称即pom.xml中的的值)

(7)设置tomcat开机自动启动

  (1)修改脚本文件rc.local:vim /etc/rc.d/rc.local

  (2)在rc.local中增加:export JAVA_HOME = jdk安装路径 ,tomcat安装路径/bin/startup.sh start

以上是“SpringBoot中war包如何部署到Tomcat服务器”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注创新互联行业资讯频道!


网页题目:SpringBoot中war包如何部署到Tomcat服务器
路径分享:http://bjjierui.cn/article/iijjdd.html

其他资讯