Build the Spring Boot project from 0 to 1

How to use IDEA to create your first Sring Boot project. String+Mybatis+Swagger+Mysql+Redis

First, preparation

Environment installation please refer to the online tutorial installation, encounter problems can be private message ball ball.

  1. JDK
  2. Mysql
  3. idea
  4. (Maven), if not installed, you can adapt to the default idea

Two, let the project take off

2.1 Installing the Boot Plug-in

Open the Plugins in Settings, check the String Boot plugin and click Apply. Ignore this step if it is already installed

2.2 Creating a String Boot Project

New Project select Spring Initializr

2.2.1 click Next

2.2.2 click Next

2.2.3 Check the required plug-ins and click Next

It doesn’t matter if you don’t have enough options here, you can just add your own dependencies to the POM file

2.2.4 Select files to create a directory and click Finish

2.2.5 Deleting Unnecessary Files

.gitignore .mvn mvnw mvnw.cmd HELP.md

2.2.6 Modifying the Default MVN Configuration File

At this point, you may find that the project import via the default MAVEN dependency of IDEA takes a long time. The waiting time may be unbearable, so you need to switch the source address of Maven

Settings_ali.xml configuration file

<?xml version="1.0" encoding="UTF-8"? >

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">

  <localRepository>/myapp/m2/repo</localRepository>
  
  <pluginGroups>
    
  </pluginGroups>

  <proxies>
    
  </proxies>

  <servers>
    
  </servers>

  
  <mirrors>
     <mirror>
      <id>nexus-aliyun</id>
      <mirrorOf>*</mirrorOf>
      <name>Nexus aliyun</name>
      <url>http://maven.aliyun.com/nexus/content/groups/public</url>
    </mirror>
  </mirrors>

  <profiles>
    
  </profiles>

</settings>

Copy the code

2.2.7 Setting the Source File Directory

If your project does not automatically set the Java directory as the source directory, you will need to do so manually

Mark Dicrectory as -> Sources Root

2.2.9 Creating a Test Control Layer

package com.qiuqiu.boot.controller;

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

@RestController
@RequestMapping("/test")
public class TestController {

    @RequestMapping("/get")
    public String info(a){
        return "this is Spring Boot"; }}Copy the code

2.2.10 Start the project

To access the address http://localhost:8080/test/get

Create visual and debug API documentation for the project

To be continued…

conclusion

  • Each post will have github code as a guide; [Github address: empty]
  • In order to make you learn more quickly, I also recorded a short and concise video; [Video address: empty]
  • Please remember: I am a life – loving, sharing cactus.
  • Life motto: mellow lovely, mellow share, mellow quiet enjoy life…