1.创建好springboot(maven)项目之后.
2.配置pom.xml
<groupId>com.atguigu</groupId>
<artifactId>boot-01-helloword</artifactId>
<version>1.0-SNAPSHOT</version>
<!--不写默认打包为:war-->
<packaging>jar</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.1</version>
</parent>
<dependencies>
<!--web场景启动器-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
<!--打包成jar-->
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
3.开始打包
4.运行jar包
windows+R ->输入cmd->回车键:
打包完成后会生成如下橘黄色的target文件,下面可以找到我们要得项目jar包,在命令行中进入到打包的路径,然后输入
java -jar 项目.jar
去运行它。
找到项目的路径: