1.请先安装springboot插件(sts),可以上网查安装步骤,也可以进入https://blog.csdn.net/lxjhzy/article/details/82586233我的这个博客第22条查看在线安装步骤
2.创建springboot项目:File----New----Other:
点击finish(也可以只点击Spring Web这一个,其余的等之后再添加)
3.项目目录:
4.打开application.properties:添加
server.port=8888
spring.datasource.url=jdbc:mysql://localhost:3306/springbootname?useCharactorEncoding=utf-8&useSSL=false
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
5.在包下新建一个类添加如下代码:
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
public class A {
@RequestMapping("/aa")
@ResponseBody
public String aa() {
return "aa";
}
}
6.点击SpringbootdemoApplication:鼠标右键Run As----Java Application:启动成功后去浏览器访问 localhost:8888/aa
访问成功,则springboot项目创建成功