Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Introduction and usage of springboot

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces "introduction and usage of springboot". In daily operation, I believe many people have doubts about the introduction and use of springboot. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "introduction and use of springboot". Next, please follow the editor to study!

Advantages of spring:

A lightweight substitute for spring's JavaEE. No need to develop heavyweight EJB,spring provides a relatively simple approach to enterprise-level java development. Through dependency injection and aspect-oriented programming, the function of EJB is realized with simple Java object.

Disadvantages of spring:

1. The component code of spring is lightweight, but its configuration is heavyweight.

2. You need to switch between thinking about the configuration of spring features and solving business problems.

3. Dependency management of the project is also a time-consuming and energy-consuming thing.

SpringBoot

SpringBoot improves and optimizes the shortcomings of the above spring, based on the idea that convention is better than configuration, so that developers do not have to switch between configuration and logic business, and devote themselves to the coding of logic business, thus greatly improving the development efficiency and shortening the project cycle to a certain extent.

Features:

1. Provide a faster entry experience for sprig-based development

2. Right out of the box, there is no code generation and no xml configuration is required. At the same time, the default value can be modified to meet specific requirements.

3. Provide some non-functional features common in large projects, such as embedded server, security, metrics, health detection, external configuration, etc.

4. Springboot does not enhance the function of spring, but provides a quick way to use spring

Core functions:

1. Start-up dependence: package the coordinates with certain functions together and provide some default functions

2, automatic configuration: in the process of running, many factors are taken into account before deciding which spring configuration should be used and which should not be used. This process is automatically completed by spring.

Getting started case:

1. Import MAVEN coordinates

Org.springframework.boot spring-boot-starter-parent 2.0.1.RELEASE UTF-8 UTF-8 1.8 org.springframework.boot spring-boot-starter-web 2.1.6.RELEASE org.springframework.boot Spring-boot-devtools org.springframework.boot spring-boot-starter-test test org.mybatis.spring.boot mybatis-spring-boot-starter 2.1.0 mysql mysql-connector-java 8.0. 15 org.springframework.boot spring-boot-starter-data-jpa javax.xml.bind jaxb-api 2.3.0 org.springframework.boot spring-boot-maven-plugin

2. Create a startup class

@ SpringBootApplication// declares that the class is a springboot bootstrap class public class MySpringBootApplication {/ / main is a java program entry public static void main (String [] args) {/ / run method indicates the bootstrap class to be springboot, and the argument is the bytecode SpringApplication.run (MySpringBootApplication.class) of the springboot bootstrap class;}}

Configuration file:

Springboot is convention-based, so many configurations have default values, but if you want to replace the default configuration with your own configuration, you can use application.properties or application.yml (application.yaml) for configuration

Yml profile:

YML file format is a file format written by YAML. YAML is an intuitive data serialization format that can be recognized by computers, and it is easy to be read by human beings, easy to interact with scripting languages, and can be imported by different programming language programs that support YAML libraries. YML files take data as the core and are more concise than traditional xml methods.

# General data configuration name: zhangsan# object data configuration person: name: zhangsan age: 18 addr: beijingserver: port: 808 configuration student: {name: zhangsan,age: 18philosophy addr: beijing} # configuration data, collection city:-beijing-tianjin-chongqing-shanghaicitys: [beijing,tianjin,chongqing,shanghai] students:-name: tom age: 18 addr: beijing-name: lucy age: 17 addr: tianjingstudentss: [{name: tom,age: 18 Addr: beijing}, {name: lucy,age: 17 name: tianjing}] map: key1: aaa key2: bbb so far The study on "introduction and use of springboot" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report