springboot部署

1.springboot简化部署

之前的J2EE项目部署需要打包成jar文件,放在tomcat服务器中,如果没有tomcat还需要配置。

现在springboot将项目打包成可执行的jar包。需要在maven依赖中导入以下扩展程序;

insert the following lines just below the dependencies section:

在pom.xml中dependencies中插入依赖

<!--增加扩展插件,可以打包  -->
  <build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

Save your pom.xml and run mvn package from the command line, as follows:

保存pom.xml文件,然后运行mvn package.

在eclipse中选择项目,右键run as ,maven  clean ,然后再运行maven install.

 在console中会显示build  success!

在eclipse中target目录中找到snapshot.jar.这个就是可执行的jar包。

从eclipse中拷贝出放在桌面中,然后cmd命令,在所在文件夹位置中java -jar 文件名称

 回车运行可以看到可以直接运行

 在浏览器中输入http://localhost:8080/hello

可以看到可执行文件可以执行。

用360压缩打开jar包,在boot-INF中有classes和lib文件夹,lib中包含了tomcat内置jar包,方便了我们部署,不用特地的在配置tomcat服务器。

原文地址:https://www.cnblogs.com/hamish26/p/12156784.html