SpringBoot快速入门(IDEA联网版)

简介: SpringBoot快速入门(IDEA联网版)

SpringBoot快速入门

@TOC

SpringBoo介绍

springboot基于spring开发,springboot本身不提供spring框架的核心特性以及扩展功能,只是用于快速、敏捷地开发新一代基于spring框架的应用程序。也就是说,它并不是用来替代spring的解决方案,而是和spring框架紧密结合用于提升spring开发者体验的工具。springboot以约定大于配置的核心思想,默认帮我们进行了很多设置,多数springboot应用只需要很少的spring配置。同时它集成了大量常用的第三方库配置,springboot应用中这些第三方库几乎可以零配置的开箱即用。

1.新建空项目

  • 选择Empty Project

在这里插入图片描述

  • 创建项目的位置

在这里插入图片描述

2.查看maven版本

  • 点击file
  • 点击setting
  • 搜索maven
  • 选择maven-3.6.0

在这里插入图片描述

3.创建新模块

  • 选择Spring Initializr
  • 配置1.8jdk
  • 选择default

在这里插入图片描述

4.springboot联网功能

  • 注意:java version与自己配置的jdk版本保持一致。下图应该为8.

在这里插入图片描述

5.选择当前模块需要使用的技术集

  • 根据自己的需求选择
  • 选择web
  • 选择SpringWeb

在这里插入图片描述

  • next

在这里插入图片描述

  • finish

在这里插入图片描述

6.项目创建成功页面

在这里插入图片描述

7.新建控制类(mvc)

package com.jkj.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/books")
public class BookController {
    @GetMapping
    public String ById(){
        System.out.println("springboot is running...");
        return "springboot is running...";
    }
}

8.测试运行

在这里插入图片描述
在这里插入图片描述

9.Springboot入门三问

  1. 你开发spring程序不写spring配置文件吗?

    不需要!
  2. 你不写配置文件你不写配置类吗?

    不需要!
  3. 那你说,你这都没有,你最起码要启动服务器吧?

    不需要!

10.最简Springboot程序基础文件

1.pom.xml

<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.7.1</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.jkj</groupId>
    <artifactId>springboot_01</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>springboot_01</name>
    <description>Demo project for Spring Boot</description>
    <properties>
        <java.version>1.8</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <!--<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>-->
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

2.pplication类

package com.jkj;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class Springboot01Application {

    public static void main(String[] args) {
        SpringApplication.run(Springboot01Application.class, args);
    }

}
相关文章
|
21天前
|
Java Maven 开发工具
IDEA使用Spring Initializr流畅的创建springboot项目
IDEA使用Spring Initializr流畅的创建springboot项目
56 0
|
1月前
|
SQL Java Maven
idea如何建立一个springboot项目
idea如何建立一个springboot项目
|
12天前
|
Java Maven
SpringBoot第一次导入项目,Maven依赖全爆红,该怎样解决,idea2019.3版本,必须用application2.7.6或者以下
SpringBoot第一次导入项目,Maven依赖全爆红,该怎样解决,idea2019.3版本,必须用application2.7.6或者以下
|
17天前
|
监控 IDE Java
探索 IntelliJ IDEA 中 Spring Boot 运行配置选项及其作用
探索 IntelliJ IDEA 中 Spring Boot 运行配置选项及其作用
23 0
|
2月前
|
Java Maven Windows
小唐开始学 Spring Boot——(1)IDEA 2021.3.2和Maven的安装配置
小唐开始学 Spring Boot——(1)IDEA 2021.3.2和Maven的安装配置
|
1月前
|
Java 编译器 Maven
使用intellij idea搭建SSM架构的maven项目 详细
使用intellij idea搭建SSM架构的maven项目 详细
47 4
|
11天前
|
IDE Oracle Java
day4:JDK、IntelliJ IDEA的安装和环境变量配置
【7月更文挑战第4天】🏆本文收录于「滚雪球学Java」专栏,专业攻坚指数级提升,希望能够助你一臂之力,帮你早日登顶实现财富自由🚀;同时,欢迎大家关注&&收藏&&订阅!持续更新中,up!up!up!!
29 0
|
14天前
|
网络协议 安全 Linux
在IntelliJ IDEA中使用固定公网地址远程SSH连接服务器环境进行开发
在IntelliJ IDEA中使用固定公网地址远程SSH连接服务器环境进行开发
20 2
|
18天前
|
IDE Java Scala
IntelliJ IDEA 2023.3 最新变化2
IntelliJ IDEA 2023.3 最新变化
27 1
|
19天前
|
Linux 开发工具 Windows
在WSL2中安装IntelliJ IDEA开发工具
在WSL2中安装IntelliJ IDEA开发工具
61 2