At the beginning of SpringBoot experience

1. Create a New Maven project

NEW profect

Modify the Setting Maven configuration to your own downloaded Maven directory

Next you’ll get a Maven project

2. Base dependency

2.1 Pom. XML file Configuration
    
      
<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>my-priject</artifactId>
    <version>1.0 the SNAPSHOT</version>
    <parent>
        <! -- Parent level version -->
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.8. RELEASE</version>
    </parent>
    <dependencies>
        <! -- Added starter-Web support to our Spring MVC-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
    </dependencies>
</project>
Copy the code
2.2 Importing Dependencies

If you click Import Changes to the POM.xml file, you’ll need to Import dependencies if you make any Changes otherwise you won’t Import dependency packages

3. Start the service

3.1 Directory Structure

Create your own com.xxx. XXX folder in the JAVA root directory based on the service interface class com.xxx.service

package com.caoben.service;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.annotation.Aspect;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;

@SpringBootApplication
public class APP {
    public static void main(String[] args) {
        // Random port start
        SpringApplication app = newSpringApplication(APP.class); app.run(args); }}Copy the code
3.2 run

Right click and run it

3.3 Interface 1

Create our Controller folder

package com.caoben.service.controller;

import com.caoben.service.Dao.UserMapper;
import com.caoben.service.allservice.SysUser;
import com.caoben.service.model.User;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/* @restController annotation: This annotation is a combination of the @Controller(mapping) and @responseBody (return type) annotations */
@RestController

public class NewControoller {

    @RequestMapping("/getHelloWord")
    public String getHelloWord(a){
        return "Hello Word SpringBoot"; }}Copy the code
Then run the 127.0.0.1:8080 / getHelloWord la SpringBoot can get resultsThe default startup port is 8080