该文的前提是已经可以在控制台运行成功,有些时候想放在tomcat里运行 大致分为如下几步

  1.配置文件更改

    

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<!-- <artifactId>spring-boot-starter</artifactId>-->
<!-- 移除嵌入式tomcat插件-->
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>

    需要移除以前的启动包添加web启动,并移除自带的然后添加如下

    

<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.</version>
<scope>provided</scope>
</dependency>

  然后将 <packaging>jar</packaging>改成 <packaging>war</packaging>

  将该包放入tomcat下面

 2.添加类SpringBootStartApplication 并继承SpringBootServletInitializer具体类代码如下:

  

package com.front.springboot;

import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer; @SpringBootApplication
public class SpringBootStartApplication extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { return builder.sources(SpringBootStartApplication.class);
} }

3.启动之后就可以看到已经可以运行了。

这里附带我最后的pom 配置文件

<?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>com.front.springboot</groupId>
<artifactId>testsSpringboot</artifactId>
<version>1.1</version>
<packaging>war</packaging> <name>Springboot</name>
<description>Demo project for Spring Boot</description> <parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.6.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<start-class> com.front.springboot.Application</start-class>
</properties> <dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<!-- <artifactId>spring-boot-starter</artifactId>-->
<!-- 移除嵌入式tomcat插件-->
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>1.17</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies> <build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build> </project>

本来准备把DEMO放上来,提示文件不能大于10M,有需要的可以留言

SpringBoot tomcat的更多相关文章

  1. springboot tomcat配置参数列表

    springboot tomcat的配置选项大全 server. Port = xxxx server. Address = server. contextPath = server. display ...

  2. eclipse+springboot+tomcat自带的部署

    最近在看微服务,然后整理了两个springboot.但执行都是内部main执行,想着后期应该会用到tomcat,大部分都是说的打成war包,然后部署到tomcat上. war包的方式就不说了,网上很多 ...

  3. springboot tomcat的使用

    使用自带的tomcat 以java 项目启动: 默认端口号为8080       1.必须导入此包       2.有启动类

  4. springboot Tomcat connector configured to listen on port 8081 failed to start.

    启动报 Tomcat connector configured to listen on port 8081 failed to start.   The port may already be in ...

  5. 无需付费,教你IDEA社区版中开发Web项目(SpringBoot\Tomcat)

    1.IDEA 版本介绍 最近有小伙伴私信我说 IDEA 破解怎么总是失效?难道就没有使用长一点的吗... 咳咳,除了给我留言「激活码」外,或许社区版可能完全满足你的需求. 相信有挺多小伙伴可能不清楚或 ...

  6. SpringBoot Tomcat启动报错

    中间的桥梁就是下面这个依赖 <dependency> <groupId>org.slf4j</groupId> <artifactId>jcl-over ...

  7. SpringBoot应用部署到Tomcat中无法启动问题

    SpringBoot应用部署到Tomcat中无法启动问题   背景 最近公司在做一些内部的小型Web应用时, 为了提高开发效率决定使用SpringBoot, 这货自带Servlet容器, 你在开发We ...

  8. SpringBoot webmvc项目导出war包并在外部tomcat运行产生的诸多问题以及解决方案

    背景: 有需求要将原来的Spring(3.2.6) + Springmvc + Hibernate项目重构为Springboot(1.5.2)项目 描述: 记录重构过程,以及期间遇到的种种问题和对应的 ...

  9. SpringBoot应用部署到Tomcat中无法启动问题(初识)

    参考http://blog.csdn.net/asdfsfsdgdfgh/article/details/52127562 背景 最近公司在做一些内部的小型Web应用时, 为了提高开发效率决定使用Sp ...

随机推荐

  1. 103041000997维护的是周批,按周合并后再考虑最小采购批量、舍入值、然后回写到SAP系统

    描述:103041000997维护的是周批量,但最终没有按周批量来回写数据. 业务逻辑如下: 1.净需求考虑数量按周汇总(也有按日.按3天,具体 要根据物料主数据维护来判断) 2.第1点的结果再加上安 ...

  2. MYSQL 备份及还原数据库

    二.还原 1.NEW DB

  3. 97. Interleaving String (String; DP)

    Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2. For example,Given:s1 = ...

  4. 836. Rectangle Overlap 矩形重叠

    [抄题]: A rectangle is represented as a list [x1, y1, x2, y2], where (x1, y1) are the coordinates of i ...

  5. 12-ssm中的description The request sent by the client was syntactically incorrect.

    此问题一般是在前端的数据传回是封装成对象失败的情况: 1.对象名不一致: 2.对象的数据类型不一致: 特别注意日期类型的: 如果前端是date数据类型的话: 传入的日期有问题 在pojo类中限定 @D ...

  6. Photoshop中比较实用的小技巧

    Photoshop是目前最流行的图片处理软件软件之一.能够说,只要接触图片处理,就要和它打交道.Photoshop的强大功能和众多的优点不用多说.用photoshop做一些漂亮的图片,或对照片进行简单 ...

  7. 想要打动HR的心,UX设计师求职信究竟应该怎么写?

    在努力准备申请一份UX设计师职位时,你最烦心和担忧的事哪一个环节?是写一份UX设计师简历?回答面试官的问题?还是在一遍遍的煎熬中等待一个面试电话?是的,这些都是不轻松的事儿,但还有一个同样糟心的事,那 ...

  8. 2、HttpClient修改处理策略Strategy

    HttpClient提供了很多接口,让我们能自定义处理逻辑,这些接口可以在AbstractHttpClient中找到: setAuthSchemes(AuthSchemeRegistry); setC ...

  9. python的介绍和及基本的使用

    一 什么是计算机 1 计算机就是由一堆硬件组成的一个机器. 2 硬件的分类: CPU:犹如人类的大脑,运行着需要运行的程序. 内存:将 CPU要运行的内容从硬盘中读取出来,然后CPU在内存里拿内容,只 ...

  10. 2018.08.27 [Usaco2017 Jan]Promotion Counting(线段树合并)

    描述 The cows have once again tried to form a startup company, failing to remember from past experienc ...