Spring Boot Framework Learn important annotations of preschool mastery (1)-java configuration method

Source: Internet
Author: User

The main contents of this section:

1: Key Notes Introduction

2: Use key annotation environment to build

Statement:

This article is the "Edith accompany you learn series-Framework learning Spring Boot Framework Learning" pre-secondary mastery of important notes (1)

The Java configuration is the recommended pie mouth method for spring 4.x. You can completely replace the XML configuration.

1: Key Notes

@configuration and @bean annotations

Description

@configuration: This annotation is used on a class, which is actually equivalent to a spring XML configuration file

@bean: This annotation acts on a method, which is actually equivalent to the <bean> node in XML.

2: Focus on the actual combat:

Actual Combat Purpose:

The example shows how to configure spring with Java configuration. And the spring IOC function is implemented

2.1: Project Creation

The MAVEN project was created:

650) this.width=650; "Src=" http://dingyue.nosdn.127.net/rcIXHUG= Xnq6gg9psd8yzqrrag3moywh4rkxi4lxkapwm1507825308462.jpg "style=" border:0px;vertical-align:middle;margin:20px 0px; " alt= "RCIXHUG=XNQ6GG9PSD8YZQRRAG3MOYWH4RKXI4LX"/>

Please click Enter picture description

650) this.width=650; "Src=" http://dingyue.nosdn.127.net/ D8oxqnqdcxhto5howfynlcefkw0evidfwbep1m428s6iz1507825308463.jpg "style=" Border:0px;vertical-align:middle;margin : 20px 0px; "alt=" D8oxqnqdcxhto5howfynlcefkw0evidfwbep1m42 "/>

Please click Enter picture description

650) this.width=650; "Src=" http://dingyue.nosdn.127.net/kE=hThq0b4atw4nBFQ8Qh0up6f2jyrL= Vteqxmbokphnk1507825308464compressflag.jpg "style=" border:0px;vertical-align:middle;margin:20px 0px; "alt=" kE= Hthq0b4atw4nbfq8qh0up6f2jyrl=vteqxmbo "/>

Please click Enter picture description

2.2:pom File Add Dependency

<parent>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-parent</artifactId>

<version>1.5.2.RELEASE</version>

</parent>

2.2.1: Add spring Boot necessary parent dependency:

650) this.width=650; "Src=" http://dingyue.nosdn.127.net/5f0=MQAcaaXleJ2V= Gsxqjmiq5ootpij64g2tmwek7pfr1507825308464.jpg "style=" border:0px;vertical-align:middle;margin:20px 0px; "alt=" 5f0 =mqacaaxlej2v=gsxqjmiq5ootpij64g2tmwe "/>

Please click Enter picture description

To add a dependency on spring MVC:

650) this.width=650; "Src=" http://dingyue.nosdn.127.net/ Kgbkirrpo0u69hzccohdhpjr0nn63iixhjyirbwz7gjf91507825308464.jpg "style=" Border:0px;vertical-align:middle;margin : 20px 0px; "alt=" Kgbkirrpo0u69hzccohdhpjr0nn63iixhjyirbwz "/>

Please click Enter picture description

To add a dependency on a database connection pool:

650) this.width=650; "Src=" http://dingyue.nosdn.127.net/7GtD1qWsVtRIsqjBshTDBzl4fKEHXZEdMeyC7vcfU= Ufx1507825308464.jpg "style=" border:0px;vertical-align:middle;margin:20px 0px; "alt=" 7GTD1QWSVTRISQJBSHTDBZL4FKEHXZEDMEYC7VCF "/>

Please click Enter picture description

Add Plugins:

650) this.width=650; "Src=" http://dingyue.nosdn.127.net/isV=0OfScX6rwEKxExowa1pdhUcwcpjov5=Oq= Ltmtjtz1507825308464.jpg "style=" border:0px;vertical-align:middle;margin:20px 0px; "alt=" isV= 0ofscx6rwekxexowa1pdhucwcpjov5=oq=lt "/>

Please click Enter picture description

Add the Tomcat plugin:

650) this.width=650; "Src=" http://dingyue.nosdn.127.net/ Q2jbe9qqozof1n48qw7rqakneq4y3ptta9fxspubwrksi1507825308464.jpg "style=" Border:0px;vertical-align:middle;margin : 20px 0px; "alt=" Q2jbe9qqozof1n48qw7rqakneq4y3ptta9fxspub "/>

Please click Enter picture description

So far. We have added the required dependencies to the Pom file.

Learn through this article:

1: Know two new annotations @configuration and @bean these two annotations exist. Get a general idea of its functionality

2:spring boot environment setup. Prepare for the next spring boot study

The next section previews:

In the next lesson, we'll focus on how to configure spring with Java configuration.

  

Welcome to the Gothic public: Edith Java

Welcome to visit Edith Personal website: www.kaigejava.com

This article in Edith Personal website address: HTTP://WWW.KAIGEJAVA.COM/ARTICLE/DETAIL/31


This article from the "Edith Java" blog, reproduced please contact the author!

Spring Boot Framework Learn important annotations of preschool mastery (1)-java configuration method

Related Article

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.