springboot Hello World

创建springboot项目:

springboot Hello World_第1张图片

pom.xml加入依赖:

com.example.demo
	springboot
	0.0.1-SNAPSHOT
	jar
  
	
		org.springframework.boot
		spring-boot-starter-parent
		2.0.0.RELEASE
		 
	

	
		UTF-8
		UTF-8
		1.8
	
 
	
		
			org.springframework.boot
			spring-boot-starter
		

		
			org.springframework.boot
			spring-boot-starter-web
		
		
		
			org.mybatis.spring.boot
			mybatis-spring-boot-starter
			1.1.1			
		
		
	
		
	

	
		
			
				org.springframework.boot
				spring-boot-maven-plugin
			
		
	

controller层使用rest风格的@RestController注解:

@RequestMapping("success")
	public String test() {
		 
		return "success";
	}

直接返回数据

创建app启动springboot项目:

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class SpringbootApplication {

	public static void main(String[] args) {
		SpringApplication.run(SpringbootApplication.class, args);
	}
}

springboot 自身有服务器,只需要启动该main方法便可启动服务器

访问浏览器:

http://localhost:8080/success

你可能感兴趣的:(springBoot)