JAVA入門(mén)教學(xué)之快速搭建基本的springboot(從spring boot到spring cloud)
安裝JDK
https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html

使用的是jdk8,這里使用的是windows10 64位的操作系統(tǒng),所以下載對(duì)應(yīng)的jdk版本

點(diǎn)擊鏈接會(huì)要你登錄,登錄以后才可以下載。

下載安裝以后找到j(luò)dk的安裝目錄,我這里是C:\Program Files\Java\jdk1.8.0_211

配置JAVA_HOME,值就是你安裝jdk的地址C:\Program Files\Java\jdk1.8.0_211 千萬(wàn)不要加bin
這個(gè)時(shí)候還沒(méi)有完成配置,還需要打開(kāi)path環(huán)境變量在最后加

加到bin目錄


如果輸入javac顯示幫助信息證明配置成功了。
下面來(lái)下載springboot的IDE,建議新手不要去搞那些插件,直接裝一個(gè)完整版本的,可以在下面的連接下載完整版。
https://spring.io/tools#main

這種下下來(lái)的jar包可以直接用解壓軟件解開(kāi),里面有直接可以執(zhí)行的exe執(zhí)行文件,直接用就可以了。



這里就勾選springweb 也就是springmvc
完成以后會(huì)發(fā)現(xiàn)下載包的速度會(huì)很慢
這時(shí)候就要自己修改maven了
http://maven.apache.org/download.cgi

修改 conf\settings.xml 設(shè)置成阿里的庫(kù),把下載源從國(guó)外轉(zhuǎn)到國(guó)內(nèi)
<mirrors> <mirror> <id>alimaven</id> <name>aliyun maven</name> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> <mirrorOf>central</mirrorOf> </mirror> </mirrors>

修改maven配置地址。重啟IDE就可以了。

package com.example.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
@ComponentScan(basePackages={"com.example.demo"})//spring服務(wù)掃描目錄。可以用*替換com.example.*
@SpringBootApplication
public class CeshiApplication {
public static void main(String[] args) {
SpringApplication.run(CeshiApplication.class, args);
}
}
package com.example.demo;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.ResourceUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/user")
public class HtuserController {
@RequestMapping("/hi")
@ResponseBody
public Returnben getsession(HttpServletRequest request, HttpSession session) {
Returnben returnben = new Returnben();
returnben.setMsg("成功");
returnben.setSuccess("1");
return returnben;
}
}
package com.example.demo;
public class Returnben {
private String success = "0";
public String getSuccess() {
return success;
}
public void setSuccess(String success) {
this.success = success;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public Object getObj() {
return obj;
}
public Object getData() {
return data;
}
public void setData(Object data) {
this.data = data;
}
public void setObj(Object obj) {
this.obj = obj;
}
private String msg = "";
private Object obj = null;
private Object data = null;
private Long count;
private int code;
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public Long getCount() {
return count;
}
public void setCount(Long count) {
this.count = count;
}
}

沒(méi)配置端口的話(huà)就是8080端口

基本的springboot就完成了,后續(xù)再說(shuō)集成各個(gè)框架和cloud其他組件
到此這篇關(guān)于JAVA入門(mén)教學(xué)之快速搭建基本的springboot(從spring boot到spring cloud)的文章就介紹到這了,更多相關(guān)springboot入門(mén)搭建內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
解決SpringBoot加載application.properties配置文件的坑
這篇文章主要介紹了SpringBoot加載application.properties配置文件的坑,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2021-08-08
springboot如何獲取接口下所有實(shí)現(xiàn)類(lèi)
這篇文章主要介紹了springboot如何獲取接口下所有實(shí)現(xiàn)類(lèi)問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-09-09
SpringMVC實(shí)現(xiàn)數(shù)據(jù)綁定及表單標(biāo)簽
這篇文章主要為大家詳細(xì)介紹了SpringMVC實(shí)現(xiàn)數(shù)據(jù)綁定及表單標(biāo)簽的相關(guān)資料,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-03-03
springboot + vue 實(shí)現(xiàn)遞歸生成多級(jí)菜單(實(shí)例代碼)
這篇文章主要介紹了springboot + vue 實(shí)現(xiàn)遞歸生成多級(jí)菜單,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2019-12-12
springboot?vue項(xiàng)目管理后端實(shí)現(xiàn)接口新增
這篇文章主要為大家介紹了springboot?vue項(xiàng)目管理后端實(shí)現(xiàn)接口新增,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-05-05
深入淺析Spring 的aop實(shí)現(xiàn)原理
AOP(Aspect-OrientedProgramming,面向方面編程),可以說(shuō)是OOP(Object-Oriented Programing,面向?qū)ο缶幊蹋┑难a(bǔ)充和完善。本文給大家介紹Spring 的aop實(shí)現(xiàn)原理,感興趣的朋友一起學(xué)習(xí)吧2016-03-03
SpringBoot中Controller參數(shù)與返回值的用法總結(jié)
這篇文章主要介紹了SpringBoot中Controller參數(shù)與返回值的用法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-07-07
Java使用數(shù)組實(shí)現(xiàn)ArrayList的動(dòng)態(tài)擴(kuò)容的方法
這篇文章主要介紹了Java使用數(shù)組實(shí)現(xiàn)ArrayList的動(dòng)態(tài)擴(kuò)容的方法,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2020-06-06

