MyEclipse springboo t项目打包 jar

1、把Spring Boot打包成JAR的形式,需要在pom.xml文件对应以下代码

    <packaging>jar</packaging>  
  
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

2、鼠标右击 pom.xml –> Run as –>Maven install

《MyEclipse springboo t项目打包 jar》

在项目target目录下生成了一个项目名称.jar是的包,之后跳转到当前项目的target文件夹下(cd target)多出两个文件。

《MyEclipse springboo t项目打包 jar》

3、启动jar包,使用CMD命令

         命令:java -jar target/jar包名称

         示例:java -jar target/springboot-0.0.1-SNAPSHOT.jar

        优化操作:

修改内存:java -Xms2048m -Xmx2048m -jar xxx.jar

可以再控制台通过命令去改端口;

例如:java -jar demo-0.0.1-SNAPSHOT.jar –server.port=8888

《MyEclipse springboo t项目打包 jar》

4、此时项目已经启动成功,可以进行访问了

          示例:http://localhost:8081/selectById?id=1

    原文作者:量子物理学
    原文地址: https://blog.csdn.net/yiyihuazi/article/details/103212531
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞