springboot項目搭建和jar運行

idea創建springboot項目
1.在這裏插入圖片描述
在這裏插入圖片描述
下一步
在這裏插入圖片描述
下一步
在這裏插入圖片描述
存放位置自行修改
在這裏插入圖片描述
2.編寫一個controller
在這裏插入圖片描述

package com.example.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {

    @RequestMapping("/hello")
    public String hello() {
        return "Hello Spring Boot!";
    }

}

3.運行DemoApplication.java
在這裏插入圖片描述
在這裏插入圖片描述
3.項目打成jar包
在這裏插入圖片描述
4.運行jar包
在這裏插入圖片描述
java -jar demo-0.0.1-SNAPSHOT.jar
在這裏插入圖片描述
在這裏插入圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章