详解IDEA搭建springBoot方式一(推荐)

1.先在IDEA配置maven

详解IDEA搭建springBoot方式一(推荐)_第1张图片

maven下载和配置可以看https://www.jb51.net/article/197309.htm

2.新建maven项目

详解IDEA搭建springBoot方式一(推荐)_第2张图片
详解IDEA搭建springBoot方式一(推荐)_第3张图片

3.在pom.xml加入springBoot依赖

详解IDEA搭建springBoot方式一(推荐)_第4张图片


  org.springframework.boot
  spring-boot-starter-parent
  1.5.9.RELEASE
 
 
  
   org.springframework.boot
   spring-boot-starter-web
  
 

4.创建类(用来启动项目),写如下代码

详解IDEA搭建springBoot方式一(推荐)_第5张图片

package xiaoliu;

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

@SpringBootApplication
public class SpringApplicationTest {
 public static void main(String[] args) {

  //启动spring应用
  SpringApplication.run(SpringApplicationTest.class,args);

 }
}

5.创建Controller 写代码如下

详解IDEA搭建springBoot方式一(推荐)_第6张图片

5.运行

详解IDEA搭建springBoot方式一(推荐)_第7张图片
详解IDEA搭建springBoot方式一(推荐)_第8张图片

6.访问项目

在页面中输入http://localhost:8080/hello 即可访问项目。

详解IDEA搭建springBoot方式一(推荐)_第9张图片

可以用idea 打包 成jar
然后用 java -jar hello.jar 运行springboot 项目
springboot中已经自带了tomcat,所以可以没有tomcat环境

到此这篇关于IDEA搭建springBoot方式一的文章就介绍到这了,更多相关IDEA搭建springBoot内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!

你可能感兴趣的:(详解IDEA搭建springBoot方式一(推荐))