SpringBoot浅浅入门
1.创建maven项目
2.导入需要的依赖
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>boot-01-helloworld</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<parent>
<artifactId>spring-boot-starter-parent</artifactId>
<groupId>org.springframework.boot</groupId>
<version>2.3.4.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.3.4.RELEASE</version>
</plugin>
</plugins>
</build>
</project>
3.创建主函数
package com.atguigu.boot;
import ch.qos.logback.core.db.DBHelper;
import com.atguigu.boot.bean.Pet;
import com.atguigu.boot.bean.User;
import com.atguigu.boot.config.MyConfig;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
/*
主程序类
@SpringBootApplication:告诉是一个SpringBoot应用*/
@SpringBootApplication
public class MainApplication {
public static void main(String[] args) {
//1.返回IOC容器
ConfigurableApplicationContext run = SpringApplication.run(MainApplication.class, args);
}
}
4.创建Controller类
package com.atguigu.boot.controller;
import com.atguigu.boot.bean.Pet;
import com.atguigu.boot.bean.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class HelloController {
@RequestMapping("/hello")
public String handle01(){
return "hello,springboot";
}
}
运行主函数即可
...全文
相关推荐
springboot+elasticsearch,入门最详细的项目
这是一个入门级别的springboot+elasticsearch的项目,内涵增删改查,值得刚入门的大兄弟们学习
springboot从入门到精通
传智博客springboot从入门到精通学习资源,内含课程文档,课程代码,如有需要视频请联系本人
SpringBoot入门Demo(非maven)
SpringBoot入门Demo(非maven)
SpringBoot实战讲解-SpringBoot从入门到精通
通过本课程的学习,全面掌握Spring Boot开发框架技术,并在实际项目开发中得心应手使用Spring Boot框架,提升自身的技术能力与价值。 适用人群:有一定的Java Web开发基础。
springboot入门demo
详情查看博客 SpringBoot笔记(一)---- 入门笔记 中的描述



