最近服務(wù)化分布式開發(fā)越來越火相艇,我也加入這個(gè)學(xué)習(xí)大軍,準(zhǔn)備寫一系列文章纯陨,就當(dāng)是自己的筆記坛芽,愿與大家共勉!
重要參考網(wǎng)址:
spring-boot官網(wǎng):https://projects.spring.io/spring-boot/
1翼抠、基本環(huán)境搭建
我的電腦環(huán)境配置如下:
Version: Neon.3 (4.6.3)
maven插件安裝
java sdk 1.8.0_131
apache-tomcat-8.0.43
2咙轩、新建maven項(xiàng)目
直接上圖,如果對maven不熟悉的阴颖,需要了解一下maven的基本使用活喊。
maven-creater1.PNG
maven-creater2.PNG
這樣一個(gè),maven項(xiàng)目就建成了量愧。
2钾菊、引入spring-boot依賴庫
在pom.xml中引入spring-boot的依賴庫
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.cqf.chapter1</groupId>
<artifactId>chapter1</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>chapter1</name>
<description>Spring Boot start first demo</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.2.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
</project>
3、啟動(dòng)類編寫
package com.cqf.chapter1;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
/**
*
* @author qifu.chen
* @version 1.0.0
* @date May 15, 2017 10:53:38 AM
*/
@Controller
@SpringBootApplication
public class Application {
@RequestMapping("/hello")
@ResponseBody
public String hello() {
return "Hello World!";
}
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
4偎肃、運(yùn)行啟動(dòng)類煞烫,啟動(dòng)成功后,在瀏覽器中輸入localhost:8080/hello累颂,即可查看到Hello World
具體詳見demo <a >chapter1</a>
你喜歡就是我最大的動(dòng)力——cqf