First, Spring boot advantages
- Tips for easier use and rapid development of spring development
- With out-of-the-box default configuration features that can be configured automatically based on project dependencies
- A more powerful service system, including embedded services, security, performance indicators, health checks, etc.
- Absolutely no code generation, no need for XML configuration to make applications lighter and more flexible
- The use of third-party technologies provides a perfect integration
Second, the project creation method
- Create a new project with Maven
- Create a new project with spring INITIALIZR (see previous article)
Three, basic dependency configuration
1 <Parent>2 <groupId>Org.springframework.boot</groupId>3 <Artifactid>Spring-boot-starter-parent</Artifactid>4 <version>1.5.6.RELEASE</version>5 <RelativePath/> <!--Lookup parent from repository -6 </Parent>7 <Dependency>8 <groupId>Org.springframework.boot</groupId>9 <Artifactid>Spring-boot-starter-web</Artifactid>Ten </Dependency>
Iv. Simple Examples
1 Package COM.SLP;2 3 import Org.mybatis.spring.annotation.MapperScan;4 import org.springframework.boot.SpringApplication;5 import org.springframework.boot.autoconfigure.SpringBootApplication;6 7 @SpringBootApplication8 @MapperScan ("Com.slp.mapper")9 Public class DemoApplication {Ten One Public static void Main (string[] args) { A Springapplication.run (Demoapplication.class, args); - } -}
Annotations @springbootapplication Annotations This is a spring boot application
The main method makes him a main program that will be executed first when the app is launched
V. Spring Boot Configuration
Create a application.properties or Application.yum file in the Project resource folder that will be automatically published to classpath and automatically read by spring boot.
Different files are configured differently, but the same parameter entries are implemented:
APPLICATION.YML:
1 Server: 2 port:803 Tomcat:4 uri-encoding:utf-8
Application.properties:
1 Server.port = 2 server.tomcat.uri-encoding = UTF-8
Spring boot&&spring Cloud Series Spring Boot initial knowledge