IntelliJ IDEA project to build entry-Spring Boot 2

Before all use Eclipse, the next test today IntelliJ IDEA, set up a Spring Boot 2 of Hello world project.

A, IntelliJ IDEA download and install

Download the official website: https: //www.jetbrains.com/idea/download/
current version is 2019.2.2.
By default setting to install after downloading.

Second, according to their needs, modify the Maven remote repository address

By default, maven will download the Apache official repository dependencies, download speed is slower.
You can maven installation directory \ conf \ setting.xml increase domestic aliyun a mirror address in order to speed up the download speed dependencies.

<mirror>
    <id>alimaven</id>
    <mirrorOf>central</mirrorOf>
    <name>aliyun maven</name>
    <url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
</mirror>

Three, IDEA project to create a Spring Boot

1, after the initial open IDEA, click on the bottom right corner of Configure, select Settings, modify the location of setting.xml maven configuration file:
File -> Settings -> Build, Execution, Deployment -> Build Tools -> Maven, modify the position of User settings file ,
the default is C: \ users \ native user name \ .m2 \ settings.xml amended as Maven and installation location of the same, I was:
the user Settings File: D: \ the Java \-the Apache Maven-3.3.9 \ conf \ the settings.xml
modify Local repository automatically becomes D: \ java \ apache-maven -3.3.9 \ repository

2. Create a Spring Boot Project
Create New Project -> Spring Initializr - > Project SDK default 1.8, Initializr Service URL default https://start.spring.io -> the Next
-> Project the Metadata of all the items to keep the default

  -> Next-> select Web, Spring Web

  -> Next

Project name: Default demo

  -> Finish

3, at the new src / main / java / com.example.demo called the controller Package, the following new class in the controller HelloWorldController 

package com.example.demo.controller;

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

@RestController
public class HelloWorldController {
    @RequestMapping("/")
    public String index() {
        return "Hello World!";
    }
}

Project is structured as follows:

  4. Click the Run button in the upper right corner, visit http: // localhost: 8080 /

Page displays: Hello World!

 

Guess you like

Origin www.cnblogs.com/gdjlc/p/11545906.html