spring boot默认创建出来的应用程序是内嵌web容器的,直接运行jar文件就可以的,但通常我们也需要将程序部署到tomcat中,这需要做如下改进:

1.pom.xml修改

打包方式需要修改成war:<packaging>war</packaging>

spring-boot-starter-web的配置中需要排除tomcat

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<artifactId>log4j-over-slf4j</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>

同时为了应用能够正常编译,还需要加上tomcat的引用:

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>

2.重写SpringBootServletInitializer类中的configure方法


  1. @Configuration
  2. @ComponentScan
  3. @EnableAutoConfiguration
  4. public class Application extends SpringBootServletInitializer {
  5. @Override
  6. protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
  7. return application.sources(Application.class);
  8. }
  9. public static void main(String[] args) {
  10. SpringApplication.run(Application.class, args);
  11. }
  12. }

最后将应用打包成war包,并将war包部署到tomcat上就可以了.

springboot 使用传统方式部署的更多相关文章

  1. springboot jar包方式部署

    打好jar包后上传到 linux 执行命令 java -jar /root/vhr-web-0.0.1-SNAPSHOT.jar > /root/log.txt & 1.java -ja ...

  2. SpringBoot 通过 Exploded Archives 的方式部署

    之前部署 SpringBoot 一直是用可执行 jar 的方式. java -jar codergroup-1.0.0.jar 就可以启动项目,为了能在后台运行,通常我们会使用这行命令 nohup j ...

  3. 关于springboot项目的jar和war两种打包方式部署的区别

    关于springboot项目的jar和war两种打包方式部署的区别 关于springboot项目的jar和war两种打包方式部署的区别? https://bbs.csdn.net/topics/392 ...

  4. springboot(十二):springboot单元测试、打包部署

    单元测试 1.在pom包中添加spring-boot-starter-test包引用 <dependency> <groupId>org.springframework.boo ...

  5. centos Linux下磁盘管理 parted,df ,du,fdisk,partprobe,mkfs.ext4,mount,/etc/fstab,fsck,e2fsck,mk2efs,tmpfs ,nr_inodes, LVM,传统方式扩容文件系统 第七节课

    centos Linux下磁盘管理   parted,df ,du,fdisk,partprobe,mkfs.ext4,mount,/etc/fstab,fsck,e2fsck,mk2efs,tmpf ...

  6. (40). springboot + devtools(热部署)【从零开始学Spring Boot】

    我们之前在在()Spring Boot热部署[从零开始学Spring Boot] (http://412887952-qq-com.iteye.com/blog/2291518 )讲过通过使用spri ...

  7. 玩转 Springboot 2 之热部署(DevTools)

    Devtools 介绍 SpringBoot 提供了热部署的功能,那啥是热部署累?SpringBoot官方是这样说的:只要类路径上的文件发生更改,就会自动重新启动应用程序.在IDE中工作时,这可能是一 ...

  8. springboot的jar包部署

    由于springboot常用war包部署,改为cloud开发模式多端口情况下,部署反而不习惯 毕竟,war包要不要项目名访问都必须放在tomcat的root目录下 而此目录限制只能放置一个项目,并且登 ...

  9. Eclipse中创建新的SpringBoot项目(打包并且部署到tomcat)

    Spring-boot因为其对jar包的高度集成以及简化服务配置,快速部署等的优点,逐渐成为Java开发人员的热衷的框架.下面演示一下怎么在Eclipse中新建Spring-boot项目以及打包部署. ...

随机推荐

  1. WSDL文档框架

  2. 【转】排列组合 "n个球放入m个盒子m"问题 总结

    出处:https://blog.csdn.net/qwb492859377/article/details/50654627 球,盒子都可以分成是否不能区分,和能区分,还能分成是否能有空箱子,所以一共 ...

  3. POJ 2983 Is the Information Reliable? 依旧差分约束

    http://poj.org/problem?id=2983 题目大意: 星际大战开始了.你购买了情报,需要判断它的准确性.已知地方的根据地在由南向北排成一条直线.P A B X,表示A在B北面距离X ...

  4. 4、C++快速入门2

    1.抽象类 如果一个类里面有纯虚函数,其被编译器认为是一个抽象类,抽象类不能用来实例化一个对象 纯虚函数定义:virtual void 函数名(void)=  0; 抽象类是给派生类定义好接口函数,如 ...

  5. 【BZOJ 3238】[Ahoi2013]差异

    [链接]h在这里写链接 [题意]     还有更简洁的题目描述吗/xk [题解]     对于lenti+lentj这一部分,比较好处理.     可以弄一个前缀和.     然后O(N)扫描一遍. ...

  6. mysql快速入门 分类: B6_MYSQL 2015-04-28 14:31 284人阅读 评论(0) 收藏

      debian方式: apt-get install mysql-server-5.5 mysql -u root -p   redhat安装方式 一.下载并解压 $ wget http://cdn ...

  7. swift开发网络篇 - 网络基础

    GET & POST GET GET的语义是获取指定URL的资源 将数据按照variable=value的形式,添加到action所指向的URL后面,并且两者使用"?"连接 ...

  8. html中radio、checkbox选中状态研究(静下心来看,静下心来总结)

    html中radio.checkbox选中状态研究(静下心来看,静下心来总结) 一.总结 1.单选框的如果有多个checked 会以最后一个为准 2.js动态添加checked属性:不行:通过 $(& ...

  9. [Angular] Separating Structural Styles From Theme Styles - Making Components Themeable

    For the component's css file, we can improt two css files: common.css default-theme.css @import &quo ...

  10. Access Violations 访问冲突(AVs)是Windows编程时发生的最麻烦的错误?

    Access Violations<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office&qu ...