[七月挑选]使用idea创建spring boot 项目


title: 使用idea创建spring boot 项目

参考lindaZ的IntelliJ IDEA 创建spring boot 的Hello World 项目


1.Open IDEA,choose "New-->Project" 2.Choose "Spring Initializr" -> next 3.Project Metadata: Group: com.chanchifeng
Artifact: server-system
Description: server-system project for Spring Boot -> next 4. Choose "Web" -> next 5.删除.mvn,mvnw,mvnw.cmd。

创建HelloController


HelloController.java: package com.chanchifeng.serversystem; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan; @SpringBootApplication
@ComponentScan("com.chanchifeng.serversystem.ctrl")
public class ServerSystemApplication { public static void main(String[] args) {
SpringApplication.run(ServerSystemApplication.class, args);
}
}

修改HelloController


package com.chanchifeng.serversystem.ctrl; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; /**
* @author:porschan
* @description:
* @date: Created in 10:14 2018/6/15
* @modified By:
*/ @RestController
@EnableAutoConfiguration
public class HelloController { @RequestMapping("/hello")
public String index(){
System.out.println("进入controller");
return "Hello World!";
}
}

运行com.chanchifeng.serversystem.ServerSystemApplication#main,在浏览器输入http://localhost:8080/hello,spring Boot项目搭建成功。

本博客来自https://chanchifeng.com/2018/06/15/idea-springboot/

上一篇:OC语言前期准备


下一篇:OC语言构造方法