1. Spring Boot start Hello World learn spring boot __spring from scratch

Source: Internet
Author: User

"Video & Communication Platform"

Àspringboot Video

Http://study.163.com/course/introduction.htm?courseId=1004329008&utm_campaign=commission&utm_source= 400000000155061&utm_medium=share

Àspringcloud Video

Http://study.163.com/course/introduction.htm?courseId=1004638001&utm_campaign=commission&utm_source= 400000000155061&utm_medium=share

àspring Boot Source

Https://gitee.com/happyangellxq520/spring-boot

àspring Boot AC Platform

http://412887952-qq-com.iteye.com/blog/2321532




1.1 Introduction

Since Structs2 's last leak, the focus on spring has become more and more strong.

Spring development used to be configured with a lot of XML, background spring joined the annotaion, making the XML configuration a lot simpler, of course, some of the configuration needs to use XML, such as the affirmation component scan.

A few days ago, Spring opened a new model Springboot, the main idea is to reduce the introduction of spring, so that beginners can speed up the program to run under the spring frame.

So how do you write Hello world?

The steps of Hello:

(1) Create a new MAVEN Java project

(2) Add spring bootmaven dependencies to pom.xml files

(3) Write startup class

(4) Running the program

1.2Hello of New

This step is very simple, compared to all of us, small in order to document the integrity of a brief description:

Start by using the IDE (ECLIPSE,MYECLIPSE) tool to create a new MAVEN project, either Maven Javaproject, or Maven Web project, to name a project. I am using MyEclipse, the project name is Spring-boot-hello1.

1.3Hello of Maven

The second step is to introduce the spring-boot-start-parent,spring official explanation in Pom.xml, which is called staterpoms, which can provide dependency management, that is to say, dependency management, The introduction will not require version when declaring other dependency, as you can see later.

<parent>
   <groupId>org.springframework.boot</groupId>
   <artifactId> spring-boot-starter-parent</artifactid>
   <version>1.3.3.RELEASE</version>
 </parent >


the mavenweb of 1.4Hello

The third step, because we are developing a Web project, we need to introduce spring-boot-starter-web,spring in Pom.xml official explanation that Spring-boot-start-web contains the spring Features of web development such as WEBMVC and Tomcat.

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


1.5Hello of Mavenrun application

If we want to start spring directly in Main, then the following plugin must be added, otherwise it will not start. This configuration is not required if you are using Maven's spring-boot:run. (When I'm testing, I run it directly in main if I don't configure the following plugin.) )

<build>
    <plugins>
           <plugin>
               <groupid>org.springframework.boot</groupid >
               <artifactid>spring-boot-maven-plugin </artifactId>
          </plugin>
      </plugins >
  </build>


the coding of 1.6Hello

The fourth step, the real program begins, we need a startup class, and then in the start class declaration let springboot automatically give us the configuration that spring needs, such as: @SpringBootApplication, in order to get the program running as quickly as possible, Let's simply write an example of a browser that accesses the word HelloWorld:

@RestController
@SpringBootApplication
publicclassapp {
  
  @RequestMapping ("/") public
  String Hello () {return
    "Hello world!";
  }
  
  Publicstaticvoid Main (string[] args) {
    springapplication.run (app.class, args);
  }
}


Where @springbootapplication affirms that spring boot is automatically configured for the program, equivalent to using the @configuration,@ with the default properties Enableautoconfiguration and @componentscan

@RestController returns the data of the JSON string, the RESTful interface can be written directly;

the run of 1.7Hello

The fifth step, is to run our application, we first introduced the first mode of operation. The first approach is particularly simple: right-click Run as-> Java application. Then open the browser to enter the address: http://127.0.0.1:8080/can see Hello world!. The second way right key Project–run As–maven build– in goals input spring-boot:run, then apply, finally click Run.

1.8Hello of Error

The smooth situation is certainly happy, but the program will often give you a little joke. So what should we pay attention to? The main version of the JDK, and so on, please see the official description:




"Spring Boot series video"

Video & Communication platform:

àspring boot NetEase Cloud Classroom Video

http://study.163.com/course/introduction.htm?courseId=1004329008

àspring Boot AC Platform

http://412887952-qq-com.iteye.com/blog/2321532

NetEase Cloud Classroom Video Latest update :

11th Chapter Spring Boot Log

1, Spring boot log-theory

2. Spring Boot log-logback

3. Spring Boot log-log4j2

12th Chapter Spring Boot Knowledge point 2

1. Spring Boot service configuration and deployment

2. Spring Boot Custom url matching rule

Historical chapters:

Chapter One Quick Start

1. Spring Boot's Hello World

2. Spring Boot's Hello World visit 404

Chapter II JSON of Spring boot

1. Spring Boot returns JSON data

2. Spring boot perfectly uses Fastjson to parse JSON data

Chapter III Thermal deployment of Spring boot

1. Spring Boot Thermal Deployment (Springloader)

2, Springboot + devtools (Hot Deployment)

Fourth Chapter Spring boot database

1. Spring Boot jpa/hibernate/spring Data concept

2. Spring Boot jpa-hibernate

3. Introduction to Spring Boot Spring Data JPA

4. Spring Boot JdbcTemplate

5. Spring Boot Integration MyBatis

Fifth Chapter Web Development

1. Global Exception capture

2. Configure Server information

3. Spring Boot uses thymeleaf

4. Spring Boot uses Freemarker

5. Spring Boot Add JSP support

Sixth Scheduled Tasks

1. Spring Boot Timing Task

2. Spring Boot Scheduled Task upgrade (dynamically modify cron parameter)

3. Spring Boot Scheduled Task upgrade (dynamic add modify delete timed Task)

4. Spring Boot Timing Task Upgrade (cluster/Distributed Timing task description)

5. Introduction to Spring Boot Quartz

6. The Spring Boot quartz is used in Java project

7, Spring Boot integrated quartz common use

8. Spring Boot Integrated Quartz upgrade version

9, Spring Boot integration Quartz two upgrade version

10. Spring Boot Integration Quartz-job How to automatically inject objects hosted by the spring container

Seventh Chapter Spring Boot MyBatis upgrade

1. Spring Boot MyBatis Upgrade-annotations

2. Spring Boot MyBatis Upgrade-annotations-self-added ID

3, Spring Boot MyBatis Upgrade-comments-additions and deletions to check

4. Spring Boot MyBatis Upgrade-annotations-paging query

5, Spring Boot MyBatis Upgrade-note-pagination pagehelper not effective

6. Spring Boot MyBatis Upgrade-annotations-mybatic Insert exception: Bindingexception:parameter ' name ' not found

7, Spring Boot mybatis upgrade-annotations-#和 $ symbol Special article

8, Spring Boot mybatis upgrade-annotations-@Result

9. Spring Boot MyBatis Upgrade-annotations-dynamic SQL (if test)-Scenario one:<script>

10. Spring Boot MyBatis Upgrade-annotations-dynamic SQL (if test)-Scenario two: @Provider

11. Spring Boot MyBatis Upgrade-annotation-Dynamic sql-parameter problem

12. Spring Boot MyBatis Upgrade-annotations-Special: @MapperScan and @mapper

13, Spring Boot mybatis upgrade article-xml

14. Spring Boot MyBatis upgrade-xml-self ID

15, Spring Boot MyBatis upgrade-xml-additions and deletions change check

16. Spring Boot MyBatis Upgrade-xml-paging query

17, Spring Boot mybatis upgrade-xml-pagination Pagehelper not effective

18. Spring Boot mybatis upgrade-xml-Dynamic SQL (if test)

19, Spring Boot mybatis upgrade-xml-annotation-initial attempt

20. Spring Boot MyBatis upgrade-Pagehelper Replace with Pagehelper-spring-boot-starter

Eighth Chapter Spring Boot Knowledge point 1

1. Spring Boot Interceptor Handlerinterceptor

2. Spring boot boot Load data commandlinerunner

3. Spring boot environment variable read and binding of Property objects

4. Spring Boot uses custom properties

5. Spring Boot uses custom properties

6. Spring Boot uses @springbootapplication

7. Spring Boot Monitor and manage production environment

Tenth chapter Spring Boot packaged Deployment

1. Spring Boot Package deployment ((SH file for Linux)

11th Chapter Spring Boot Log

1, Spring boot log-theory

2. Spring Boot log-logback

3. Spring Boot log-log4j2


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.