idea搭建springboot项目
- 1.点击idea左上角file-new-project
- 2.选择spring initializr,填写好工程名,选好工程存放地址,填写好包名,pakaging选择jar包==注意:server url默认为https://start.spring.io,有可能连接不上,可以点击右边的设置按钮,把网址换成https://start.aliyun.com==
- 3.点击next,这里可以添加项目所需要的依赖,点击finish完成项目创建。
- 4.项目结构如下
- 5.在file-settings-搜索maven,配置项目本地仓库的地址
- 6.启动项目,运行启动类
- 7.在pom.xml中添加依赖,创建com.zyp.zypideaproject2.controller.User类
1.点击idea左上角file-new-project
2.选择spring initializr,填写好工程名,选好工程存放地址,填写好包名,pakaging选择jar包注意:server url默认为https://start.spring.io,有可能连接不上,可以点击右边的设置按钮,把网址换成https://start.aliyun.com
3.点击next,这里可以添加项目所需要的依赖,点击finish完成项目创建。
4.项目结构如下
== 文件中文字体乱码可以在file-setting-搜索file encodings设置==
5.在file-settings-搜索maven,配置项目本地仓库的地址
6.启动项目,运行启动类
出现下图则代表soringboot项目启动中
7.在pom.xml中添加依赖,创建com.zyp.zypideaproject2.controller.User类
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
@RestController
public class user {
@RequestMapping("hello")
public String hello(){
return "hello springboot!";
}
}
浏览器访问http://localhost:8080/hello,看到如下效果则代表项目搭建成功。