from :Spring Boot( One ): Introduction

What is? Spring Boot

Spring Boot By Pivotal A new framework from the team , It is designed to simplify the new Spring Initial setup and development of the application . The framework is configured in a specific way , This eliminates the need for developers to define boilerplate configurations . Take it in my words , Namely Spring Boot Not really a new framework , By default, it configures many ways to use the framework , It's like Maven It integrates all of them Jar package ,Spring Boot Integrated all the frameworks .

Use  Spring Boot What are the benefits

In fact, it's simple 、 Fast 、 convenient ! Usually if we need to build a Spring Web What do I need to do with the project ?

  • 1) To configure web.xml, load Spring and Spring mvc
  • 2) Configure database connections 、 To configure Spring Business
  • 3) Configure the load read of the configuration file , Open the annotation
  • 4) Configure log files
  • ...
  • Deploy after the configuration is complete Tomcat debugging
  • ...

Microservices are very popular now , If my project just needs to send an email , If my project is just to produce a point ; I need to toss like this !

But if you use Spring Boot Well ?
It's simple , I only need a few configurations to build a set quickly and conveniently Web Project or build a microservice !

Quick start

Said so much , It's itchy , Try it right away !

Maven Build the project

  • 1、 visit
  • 2、 Choose the build tool Maven Project、Java、Spring Boot edition 2.1.3 And some basic engineering information , Please refer to the figure below :

  • 3、 Click on Generate Project Download project zip
  • 4、 After decompressing , Use Idea Import the project ,File -> New -> Model from Existing Source.. -> Select the unzipped folder -> OK, choice Maven All the way Next,OK done!
  • 5、 If you are using Eclipse,Import -> Existing Maven Projects -> Next -> Select the unzipped folder -> Finsh,OK done!

Idea Build the project

  • 1、 choice File -> New —> Project... Pop up the new item box
  • 2、 choice Spring Initializr,Next A similar configuration interface will also appear ,Idea Helped us with the integration
  • 3、 After filling in the relevant content , Click on Next Select the dependent package and click Next, Finally, make sure the information is correct Finish.

Introduction to project structure

As shown in the figure above ,Spring Boot There are three files in the infrastructure :

l src/main/java  Program development and main program entry

l src/main/resources The configuration file

l src/test/java  The test program

in addition ,spingboot The recommended directory results are as follows :

root package structure :com.example.myproject

+- example
+- myproject
+- domain
| +-
| +-
+- service
| +-
+- controller
| +-

1、  It's suggested to put it under the table of contents , Mainly used to do some framework configuration

2、domain Directories are mainly used for entities (Entity) And data access layer (Repository)

3、service  Layer is mainly business code

4、controller  Responsible for page access control

Using the default configuration can save a lot of configuration , Of course, you can also change it according to your preference

Last , start-up Application main Method , At this point java The project is set up !

introduce Web  modular

1、pom.xml Add support web Module :


pom.xml There are two modules in the file by default :

spring-boot-starter: Core module , Including auto configuration support 、 Journal and YAML;

spring-boot-starter-test: Test module , Include JUnit、Hamcrest、Mockito.

2、 To write controller Content

public class HelloWorldController {
public String index() {
return "Hello World";

@RestController It means controller All the methods in it are json Format output , No more writing jackjson Configured !

3、 Start main program , Open browser access http://localhost:8080/hello, And you can see the effect , It's easy to have wood !

Reference material :

Spring Boot actual combat : Line by line interpretation HelloWorld

Spring Boot( One ): Introduction + Front end access back end more related articles

  1. Spring Boot -01- Quick start ( Text course )

    Spring Boot -01- Quick start ( Text course ) I'm starting to sort it out today Spring Boot 2.0 Version learning notes , You can see my notes on my blog , Then you can go to the video course if you want to [ For class network ] mobile phone app ...

  2. spring boot Introduction to learning 【spring boot How to build a project and how to load it jsp Interface 】

    [ Preface ]  Spring Boot brief introduction :Spring Boot By Pivotal A new framework from the team , It is designed to simplify the new Spring Initial setup and development of the application . The framework is configured in a specific way , ...

  3. spring boot Introductory tutorial ——Spring Boot Quick Start Guide

    Spring Boot It has become the most popular microservice development framework , How to use Spring Boot Quick start Web A guide to microservice development , We will make it possible to create a runnable include inline Web Containers ( The default is Tomcat) Good luck ...

  4. Spring Boot From entry to mastery ( 5、 ... and ) Multi data source configuration implementation and source code analysis

    Multi data source configuration is a common development requirement in project software ,Spring and Spring Boot There are corresponding solutions for your reference . stay Spring Boot in , Such as MyBatis.JdbcTemplate as well as Jpa ...

  5. Spring Boot From entry to mastery ( 6、 ... and ) Integrate Redis Implement caching mechanism

    Redis(Remote Dictionary Server ), Remote dictionary service , Is an open source use ANSI C Language writing . Support network . Log type that can be memory based or persistent .Key-Value database , And offers multiple languages ...

  6. Spring Boot From entry to mastery ( 7、 ... and ) Integrate Redis Realization Session share

    Single sign on (SSO) It refers to multiple application systems , Login users only need to login and verify once to access all mutual trust application systems ,Redis Session Sharing is a way to achieve single sign on . This article is through Spring Boot Framework for the integration Re ...

  7. Spring Boot From entry to mastery ( Nine ) Integrate Spring Data JPA Application framework

    JPA What is it? ? JPA Full name Java Persistence API, yes Sun official Java Persistence specification . yes JDK 5.0 Note or XML Describe objects - Mapping of relational tables , And persist the running entity object into the database . ...

  8. Spring Boot Quick start

    Spring Boot Quick start Today I'd like to introduce to you Spring Boot MVC ...

  9. Spring Boot Quick start ( Two ):http request

    Original address : One . Get ready postman: An interface testing tool Create a new project choice web No, please see Spring Boot Quick start ( One ):Hel ...

Random recommendation

  1. cocoapods Installation error

    Carry out today pod install when , There was a mistake , Prompt update , good , Then update ; 1. The terminal executed the next :gem sources -l   Check out the next source *** CURRENT SOURCES *** https:// ...

  2. redis Invasion summary

    redis install : windows Installation package : After downloading , Start installation : redis-server.exe redis.conf: One simple step , Ann ...

  3. Myeclipse Use of shortcut keys

    Save Ctrl+s( Must know ) Comment code Ctrl+/ uncomment Ctrl+\(Eclipse3 It's all merged into Ctrl+/ 了 ) Code assisted Alt+/ Quick fix Ctrl+1 Code formatting Ctrl+Shi ...

  4. JQuery Common methods basic course

    In this paper, from ( For learning to use jquery Friend, , It can be used to , Simply understand jque ...

  5. aspx Use... In the page Input Tag to upload pictures

    To achieve the function of uploading pictures, a separate aspx page , The front page needs to pay attention to two points : a) Implementation of upload function input Of type="file" b) Set the request message header to enctype=" ...

  6. MyArrayList—— Realize one's own ArrayList!

    notes : Reprint please indicate the original address : ArrayList Is one of our common collection classes , In fact, its implementation mechanism is very simple , The bottom layer still uses a ...

  7. Android Layout optimization include、merge、ViewStub Use

    This paper aims at include.merge.ViewStub How to reuse three tags in layout . How to effectively reduce the layout level and how to load on demand are introduced in three aspects . Reusing layouts can help us create complex layouts that can be reused . It also means ...

  8. Spring adopt AOP Realize to Redis Cache synchronization for

    I don't say much nonsense On thinking : Use aop annotation , stay Service To add classes, you need to use redis On the way , When each request comes, it will be intercepted , If it is a query, the redis Conduct get key, If it is update Delete key, prevent ...

  9. textarea No dragging

    <textarea style="resize:none;" ></textarea>'

  10. ITU-T Technical Paper: IP Network measurement model

    This article is translated from ITU-T Of Technical Paper:<How to increase QoS/QoE of IP-based platform(s) to regionally agreed ...