Loading

SpringBoot部署

SpringBoot 项目开发完毕后,支持两种方式部署到服务器:

①jar包(官方推荐)

②war包

更改pom文件中的打包方式为war

<packaging>war</packaging>

修改启动类:

继承SpringBootServletInitializer类并重写configure方法:

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;

@SpringBootApplication
public class SpringbootDeployApplication extends SpringBootServletInitializer {

    public static void main(String[] args) {
        SpringApplication.run(SpringbootDeployApplication.class, args);
    }


    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        return builder.sources(SpringbootDeployApplication.class);
    }
}

指定打包的名称

 <build>
        <finalName>springboot</finalName>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

 彩蛋:

修改springboot启动时默认显示字符:

  只需要在resources下新建一个txt文件就可以,命名为banner.txt,拼接字符的一个网址,链接传送门:字母转字符

 

posted @ 2021-07-12 10:11  1640808365  阅读(474)  评论(0编辑  收藏  举报