The background,

Companies are responding to the call of The Times by replacing PHP with Java, so they are starting to learn Java in order to survive.

I plan to record my learning process from time to time, and I hope I can successfully transform into a qualified Java big white!

My Java colleague told me to learn Spring Boot directly, so I officially started my learning journey.

Second, the target

What is the first step in learning a language?

Output Hello Word!!

So my goal today is to output Hello Word!

Three, process,

(1) The environment has been done once before, again will not explain what the configuration process, the online data are quite full. The development tool is IntelliJ IDEA.

(2) To create a project, because it is just a simple practice project, so there is no need to consider the improvement of information, everything is used by default

1.File->new->project

2. Select Spring Initializr

3. Click Next by default

4. Under Web, select Spring Web (ps: online create Springboot projects usually select Web options, and select Spring Web Start for higher versions of Springboot, 2.1.8 is Spring Web)

5. Click Finish

(3) Maven package guide

1. Enter the project, click Maven on the right, and click Settings (wrench icon) to configure the Project Maven warehouse;

(4) wait for after the completion of the automatic guide Package, began to create a directory in the SRC/main/Java/com. The example. The demo right click – > New – > Package, a New controller directory, and build a directory HelloController class, add the following code

package com.example.demo.controller;

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


@RestController
public class HelloController {
    @RequestMapping("/sayHello")
    public String sayHello() {
        return "Hello Word!";
    }

    @RequestMapping("/helloByParam")
    public String helloByParam(@RequestParam(value = "name") String name) {
        return "Hello ,"+ name; }}Copy the code

(5) find SRC/main/Java/com. The example. The demo/DemoApplication, this is the entrance to the file, run it up!

Four,

Port is set to 8080, @ RequestMapping (“/sayHello “) on behalf of the request uri of/sayHello, so directly on the browser to http://localhost:8080/sayHello, you can see “Hello Word!” .

Goal accomplished, call it a day!

Five, the afterword.

There is a long way to go

Grow record portal

The realization of the curl