美文网首页
springboot 配置外部容器 17

springboot 配置外部容器 17

作者: 张力的程序园 | 来源:发表于2020-04-06 20:13 被阅读0次

    众所周知,springboot默认使用内置tomcat,但我们也可以使用外部tomcat。

    1、环境约束

    • win10 64位操作系统
    • idea2018.1.5
    • maven-3.0.5
    • jdk-8u162-windows-x64

    2、前提约束

    3、操作步骤

    • 主启动类继承SpringBootServletInitializer,并重写configure方法
    public class SpringbootDemoApplication extends SpringBootServletInitializer {
    
        @Override
        protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
            return application.sources(SpringbootDemoApplication.class);
        }
    
        public static void main(String[] args) {
            SpringApplication.run(SpringbootDemoApplication.class, args);
        }
    
    • 在pom.xml中加入:
        <packaging>war</packaging>
    
    • 在pom.xml中加入依赖:
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-tomcat</artifactId>
                <scope>provided</scope>
            </dependency>
    
    • clean->install->绑定tomcat->启动即可。
      以上就是springboot绑定外部容器的过程。

    相关文章

      网友评论

          本文标题:springboot 配置外部容器 17

          本文链接:https://www.haomeiwen.com/subject/vtkiphtx.html