第一步:建maven项目,导入父工程
org.springframework.boot
spring-boot-starter-parent
2.3.4.RELEASE
第二部:导入依赖
org.springframework.boot spring-boot-starter-web
第三步:创建一个主程序入口
@SpringBootApplication
public class MainApplication {
public static void main(String[] args) {
SpringApplication.run(MainApplication.class,args);
第四步:编写一个业务
@RestController
public class Controller1 {
@RequestMapping("/hello")
public String handle01(){
return "hello,springboot2!";
}
}
第五步:测试
运行主程序
url访问:localhost:8080/hello
第六步:配置文件(application.properties)
#端口号 访问地址改为:localhost:8888/hello server.port=8888
第七步:打成jar包 (包内包含运行的所有需要)
–在这里加个打包配置
org.example boot-01-helloworld 1.0-SNAPSHOT jar
–导入需要的插件
org.springframework.boot spring-boot-maven-plugin
–选中clean和package点击启动,打包完成
打包完成后即可在目标文件下找到xxx.jar
最后这个jar包即可在目标主机上单独运行



