全国免费服务热线:

18982081108
✕

成都弹性云服务器,成都高防云服务器,互联网数据服务,成都祈钰瑶

springBoot打包部署到远程服务器的tomcat中-创新互联

前言

成都创新互联服务项目包括寿光网站建设、寿光网站制作、寿光网页制作以及寿光网络营销策划等。多年来,我们专注于互联网行业,利用自身积累的技术优势、行业经验、深度合作伙伴关系等,向广大中小型企业、政府机构等提供互联网行业的解决方案,寿光网站推广取得了明显的社会效益与经济效益。目前,我们服务的客户以成都为中心已经辐射到寿光省份的部分城市,未来相信会继续扩大服务区域并继续获得客户的支持与信任!

Spring Boot项目一般都是内嵌tomcat或者jetty服务器运行,很少用war包部署到外部的服务容器,即使放到linux中,一般也是直接启动Application类,但是有些时候我们需要部署到外部的服务器,这对于Spring Boot来说却有点麻烦

下面话不多说了,来一起看看详细的介绍吧。

环境声明:


jdk:1.8


服务器:阿里云,ubuntu 16.04


springBoot:1.5.9.RELEASE

目的


将springBoot 打包到远程服务器的tomcat中。

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 <modelVersion>4.0.0</modelVersion>
 <groupId>waibao</groupId>
 <artifactId>project</artifactId>
 <version>1.0-SNAPSHOT</version>
 <packaging>war</packaging>
 <parent>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-parent</artifactId>
  <version>1.5.9.RELEASE</version>
 </parent>
 <properties>
  <java.version>1.8</java.version>
 </properties>
 <dependencies>
  <dependency>   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-web</artifactId>
  </dependency>  
  <!-- 移除tomcat的支持,改成编译时支持 -->
  <dependency>   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-tomcat</artifactId>
   <scope>provided</scope>
  </dependency>
  <dependency>   <groupId>org.mybatis.spring.boot</groupId>
   <artifactId>mybatis-spring-boot-starter</artifactId>
   <version>1.3.1</version>
  </dependency>
  <!--非严格模式 -->
  <dependency>   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-thymeleaf</artifactId>
  </dependency>
  <!-- 配置thymeleaf的非严格模式,需要该依赖-->
  <dependency>   <groupId>net.sourceforge.nekohtml</groupId>
   <artifactId>nekohtml</artifactId>
   <version>1.9.22</version>
  </dependency>
  <dependency>   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-jdbc</artifactId>
  </dependency>
  <dependency>   <groupId>org.mybatis.spring.boot</groupId>
   <artifactId>mybatis-spring-boot-starter</artifactId>
   <version>1.3.1</version>
  </dependency>
  <dependency>   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-test</artifactId>
   <scope>test</scope>
  </dependency>
  <dependency>
   <groupId>mysql</groupId>
   <artifactId>mysql-connector-java</artifactId>
   <version>6.0.6</version>
  </dependency>
  <!-- 阿里连接池-->
  <dependency>
   <groupId>com.alibaba</groupId>
   <artifactId>druid</artifactId>
   <version>1.1.5</version>
  </dependency>
  <!-- fastJson -->
  <dependency>
   <groupId>com.alibaba</groupId>
   <artifactId>fastjson</artifactId>
   <version>1.2.40</version>
  </dependency>
  <!-- 热部署-->
  <dependency>   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-devtools</artifactId>
   <version>1.5.9.RELEASE</version>
   <optional>true</optional>
   <scope>true</scope>
  </dependency>
 </dependencies>
 <build>
  <finalName>/testweb</finalName>
  <plugins>
   <plugin>    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.4</version>
    <configuration>
     <failOnMissingWebXml>false</failOnMissingWebXml>
    </configuration>
   </plugin>
  </plugins>
 </build>
</project>