手把手教你如何優雅的使用idea建立屬於你的第一個Sring Boot項目。 本次教程使用到的技術棧 String+Mybatis+Swagger+Mysql+Redisphp
環境安裝請你們參考網上教程自行安裝,遇到問題可私信 球球。html
打開Settings裏面Plugins,勾選String Boot插件而後點擊Apply,若是已經安裝了可忽略次步驟 java
New Project 選擇Spring Initializrgit
此處不夠選的也不要緊能夠在pom文件中自行添加依賴就好了github
.gitignore .mvn mvnw mvnw.cmd HELP.mdweb
此時你會發現,項目經過idea默認的maven依賴導入很漫長,這個等待的時間能夠說是沒法忍受的,因此須要切換maven的源地址spring
settings_ali.xml 配置文件sql
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>/myapp/m2/repo</localRepository>
<pluginGroups>
</pluginGroups>
<proxies>
</proxies>
<servers>
</servers>
<mirrors>
<mirror>
<id>nexus-aliyun</id>
<mirrorOf>*</mirrorOf>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>
</mirrors>
<profiles>
</profiles>
</settings>
複製代碼
若是你的項目沒有自動設置java目錄爲源文件目錄的話,須要手動設置apache
Java目錄下右鍵->Mark Dicrectory as -> Sources Rootapp
package com.qiuqiu.boot.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/test")
public class TestController {
@RequestMapping("/get")
public String info(){
return "this is Spring Boot";
}
}
複製代碼
訪問地址 http://localhost:8080/test/get
未完待續。。。