helloworld project presentations and spring boot

spring boot Introduction

spring boot history, background online a lot, is a rapid development framework for enterprise-class web projects, the follow-up to fix the difference between the spring and spring MVC

helloworld project structure and presentation

Create a spring boot project in IDEA

IDEA create File -> New -> Project
enter description here

Version: java: 10.0.2 IDEA: IDEA (Ultimate Edition) 2019.2.3 students registered version

No spring initializer of the need to install plug-in plug-in spring boot
enter description here

Click next

The reason sprint boot connection is not: being given Cannot download https://start.spring.io;Status:403
Solution: open phone hot, hot mobile phone connected to the computer

Modify good information
enter description here

Dependence select spring web
enter description here

Once created, you can delete some unnecessary files
enter description here

Hello World example program

The application.properties into application.yml. yml file properties and configuration files that have the same function. Two differences:

  • Yml file hierarchy is more clear and intuitive, but note that the format when writing indent alignment. yml configuration file format is more conducive to the expression of the configuration of complex data structures. For example: a list of objects (later chapters will explain in detail).
  • Read on properties as good as yml intuitive benefits that do not pay particular attention to writing format indentation aligned.

application.yml file can be modified to open a web page port

server:
  port: 8888   # web应用服务端口

Added in pom.xml

<dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
</dependency>

Create a controller folder com.xxxx.bootlauch> java> - in src -> mian
create a HelloControllerclass, enter

@RestController
public class HelloController {
    @RequestMapping("/hello")
    public String hello(String name) {
        return "hello world, " +name;
    }
}

After clicking start, you can get in the browser input http://127.0.0.1:8080/hello
enter description here

Table of Contents Introduction Project Structure

enter description here
Project directory structure maven generally in accordance with regulatory requirements:

enter description here

  • src / main / resources / static mainly used to store css, images, js and other static files with the development
  • src / main / resources / public used to store can be directly used to access html file
  • src / main / resources / templates template files used to store web development

reference

  1. Hand touch hand to teach you to learn the Boot 2.x the Spring
    2. "layman Spring Boot 2.x"
  2. August 2019 The new Spring boot2.0 full set of video tutorials

Guess you like

Origin www.cnblogs.com/xiao7462/p/11762868.html