zoukankan      html  css  js  c++  java
  • 用tomcat启动spring-boot

    两种做法

    修改Appcation.java文件

    package com.techny.lianmai;
    
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.boot.builder.SpringApplicationBuilder;
    import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
    import org.springframework.context.annotation.ComponentScan;
    
    @SpringBootApplication
    @ComponentScan(basePackages = {"com.techny.lianmai.*"})  //指定扫描包路径
    public class LianmaiApplication extends SpringBootServletInitializer {
    
        @Override
        protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
            return application.sources(LianmaiApplication.class);
        }
    
        public static void main(String[] args) {
            SpringApplication.run(LianmaiApplication.class, args);
        }
    
    }

    或者添加一个文件ServletInitializer.java

    package com.techny.lianmai;
    
    import org.springframework.boot.builder.SpringApplicationBuilder;
    import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
    
    public class ServletInitializer extends SpringBootServletInitializer {
    
        @Override
        protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
            return application.sources(LianmaiApplication.class);
        }
    
    }

    可以正常进入网页

    论读书
    睁开眼,书在面前
    闭上眼,书在心里
  • 相关阅读:
    centos6和centos7升级openssh7.5脚本
    开通telnet服务,使用telnet登入
    彻底删除kafka的topic以及其中的数据
    redis集群创建
    curl 命令参数
    nginx.conf配置文件详解,白嫖的
    logstash迁移es数据
    es 常用查询
    pl/sql 存储过程
    es查看集群信息命令_cat和_cluster
  • 原文地址:https://www.cnblogs.com/YC-L/p/14300601.html
Copyright © 2011-2022 走看看