idea 創建 spring boot 項目。輸出 “Hello World!”

1.創建

 

2.創建信息

 next

 點 finish

 

3.創建好後,項目長這樣:

 

4.配置 maven。如果側邊沒有 maven 選項卡 ,參考這篇 https://www.cnblogs.com/cynthia-wuqian/p/17460845.html

 

 

 

5.啓動項目

 

6.修改文件,跑 Hello World !

 # index.html 文件

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
Hello World !
</body>
</html>

# application.properties 文件

server.port=8082
server.tomcat.uri-encoding=utf-8

# application.yml 文件

spring:
  datasource:
    url: jdbc:mysql://localhost:3306/student
    dirver-class-name: com.mysql.jdbc.Driver
    username: admin
    password: 123456

 

 

7.修改完成以後,點擊 run 按鈕。打開頁面 http://localhost:8082/ ,可以看到:

 

 

8.到7只是展示了 index.html 頁面內容,還沒有和數據庫交互。關於上面的 application.yml 的數據庫連接,可以通過 idea 的 plugin -- Database 來創建

 

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