spring boot 部署项目

这篇博客介绍了如何使用Maven在IDEA中打包Spring Boot项目,生成的jar包可以通过指定命令行以管理员权限运行。文章提供了详细的步骤,包括转盘命令、cd命令的使用,以及成功运行的标志。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

spring boot 部署项目

  1. 导入相关依赖

    <!--这个插件可以将应用打包成可执行的jar包-->
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    
  2. 等待依赖加载完成,使用maven完成打包
    点击即可

  3. idea控制台打印结果

E:\Java\jdk1.8\bin\java -Dvisualvm.id=2676002024106 -Dmaven.multiModuleProjectDirectory=E:\idea文件\spring-boot\springboot01helloword -Xms256m -Xmx512m -Dfile.encoding=utf-8 -Dmaven.home=E:\apache-maven-3.5.2 -Dclassworlds.conf=E:\apache-maven-3.5.2\bin\m2.conf “-javaagent:E:\idea相关\IntelliJ IDEA 2017.3.6\lib\idea_rt.jar=52561:E:\idea相关\IntelliJ IDEA 2017.3.6\bin” -classpath E:\apache-maven-3.5.2\boot\plexus-classworlds-2.5.2.jar org.codehaus.classworlds.Launcher -Didea.version=2017.3.6 -s E:\apache-maven-3.5.2\conf\settings.xml package
[INFO] Scanning for projects…
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building spring-boot01-helloword 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] — maven-resources-plugin:2.6:resources (default-resources) @ spring-boot01-helloword —
[INFO] Using ‘UTF-8’ encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO] Copying 0 resource
[INFO]
[INFO] — maven-compiler-plugin:3.1:compile (default-compile) @ spring-boot01-helloword —
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 2 source files to E:\idea�ļ�\spring-boot\springboot01helloword\target\classes
[INFO]
[INFO] — maven-resources-plugin:2.6:testResources (default-testResources) @ spring-boot01-helloword —
[INFO] Using ‘UTF-8’ encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory E:\idea�ļ�\spring-boot\springboot01helloword\src\test\resources
[INFO]
[INFO] — maven-compiler-plugin:3.1:testCompile (default-testCompile) @ spring-boot01-helloword —
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] — maven-surefire-plugin:2.18.1:test (default-test) @ spring-boot01-helloword —
[INFO] No tests to run.
[INFO]
[INFO] — maven-jar-plugin:2.6:jar (default-jar) @ spring-boot01-helloword —

[INFO] Building jar: E:\idea�ļ�\spring-boot\springboot01helloword\target\spring-boot01-helloword-1.0-SNAPSHOT.jar

[INFO]
[INFO] — spring-boot-maven-plugin:1.5.9.RELEASE:repackage (default) @ spring-boot01-helloword —
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.738 s
[INFO] Finished at: 2019-11-02T13:20:12+08:00
[INFO] Final Memory: 27M/275M
[INFO] ------------------------------------------------------------------------

黑体字加粗部分是jar包的路径

  1. 运行jar包
    (1)把jar包移到桌面上/移到一个你知道的文件夹下/或不移动
    (2)使用管理员权限运行命令窗口 (win7可以使用windows+r 即可 /win10需手动调出cmd窗口的位置到桌面上。右键使用管理员权限)
    (3)使用转盘命令e: 可转盘 cd 详细路径,建议复制 等等,移动到jar包对应的文件的上一层
    (4)使用java -jar jar包名字 下面是我使用的命令 回车执行即可
    java -jar spring-boot01-helloword-1.0-SNAPSHOT.jar
    在这里插入图片描述
    成功标志
    在这里插入图片描述
    一旦关闭命令提示符窗口服务器就关闭了
    (5)测试项目接口
    在这里插入图片描述
    成功!

本文若有错误请指正,互相学习,加油!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值