• linux服务器使用tomcat部署springboot项目


    linux服务器使用tomcat部署springboot项目

    一、项目达成war包

    注意点:
    1)maven文件中配置打包方式:<packaging>war</packaging>
    2)修改打包名称,项目访问依赖此名称:在<build>中增加<finalName>photos</finalName>
    

    二、将war包上传到tomcat目录webapps中,启动tomcat会自动解压

    1)启动命令:sh bin/startup.sh
    2)可使用rz命令上传war包。
    

    三、存在的问题

    1. 现象

      项目启动后,tomcat访问正常,没有spring启动日志,项目访问报404异常。

    2. 原因分析

      springboot项目默认使用内置tomcat启动服务,如果需要外部tomcat启动需要屏蔽springboot中tomcat容器。

    3. 解决方案

      1)增加maven依赖
      <dependency>
                  <groupId>org.springframework.boot</groupId>
                  <artifactId>spring-boot-starter-tomcat</artifactId>
                  <scope>provided</scope>
      </dependency>
      
      2)修改启动器
      public class SpringbootApplication extends SpringBootServletInitializer {
      
          public static void main(String[] args) {
              SpringApplication.run(SpringbootApplication.class, args);
          }
          //重写configure方法
          @Override
          protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
              return builder.sources(SpringbootApplication.class);
          }
      }
      
  • 相关阅读:
    Python获取秒级时间戳与毫秒级时间戳
    时间戳与时间类型转化(秒级时间戳)
    linux压缩和解压缩命令
    对于Python中@property的理解和使用
    探索性测试方法
    Linux 中 grep 命令的 12 个实践例子
    在 Linux 启动或重启时执行命令与脚本
    亲测的orabbix监控Oracle过程
    find 使用搜集
    Centos7.3-mysql5.7复制安装过程
  • 原文地址:https://www.cnblogs.com/liyefei/p/15916553.html
Copyright © 2020-2023  润新知