[springboot2 starts from 0] how to write a springboot application?

Bite the apple and cry 2021-09-15 06:59:02
springboot2 springboot starts write springboot


How to write springboot application ? In fact, there is a way .

One 、 Introduce scenario dependency

Since we want to develop springboot application , The scene must be clear first , such as web、 cache 、 Message queuing, etc .

Then find the relevant scenario dependencies according to the specific scenario , This includes springboot Provided rely on , It also includes scenario dependencies provided by third parties .

And then in pom.xml Just introduce , For example, it introduces spring-boot-starter-web.

Two 、 View auto configuration

This is not necessary , After introducing scenario dependency, direct development can also . If you want to know which configurations are enabled , You can check it .

Here's a way , Can be in application.properties Add configuration in configuration file , Turn on debug Pattern :

# Turn on debug Pattern
debug=true
 Copy code 

At this time, when starting the application , You can see more log output on the console , Effective and ineffective configurations are included here .

  • Negative matches: Configurations with insufficient conditions are listed here , It didn't work .

  • Positive matches: The configurations that meet the conditions are listed here , Is effective .

Corresponding effective configuration , If you are interested, you can refer to the previous automatic configuration process , To analyze a wave of .

3、 ... and 、 Need to modify

1. Modify configuration items by referencing documents

After dependency injection , Confirm whether there are configuration items that need to be modified .

such as , Using a database or something , Naturally, you want to configure the user name used for the connection 、 Passwords and so on .

You can refer to when modifying the configuration Official documents , Find the corresponding configuration item to modify .

There are many configuration items here , for instance , Let's configure the display when the application starts banner chart , The default is this :

I'll replace it with another picture now , Just use the official account. , Put the picture banner1 Put it in resources Under the table of contents :

Found in the document Core Properties Inside spring.banner.image.location.

Configuration to application.properties In the document :

spring.banner.image.location=classpath:banner1.jpg
 Copy code 

Start the application , Look at the effect :

Configuration is successful .

2. Add a custom component or replace the original component

If the configuration is changed in some cases, it still does not meet the requirements , We can also customize components , To increase our customized functions , Direct yourself @Bean Replace underlying components .

although springboot There is much more in the , But the above steps have been completed ,springboot You can basically use it .

版权声明
本文为[Bite the apple and cry]所创,转载请带上原文链接,感谢
https://javamana.com/2021/09/20210909124112667u.html

  1. Opérateurs arithmétiques et opérateurs de comparaison pour JavaScript, Introduction classique au développement web
  2. MySQL + +: slow query log analysis (I)
  3. Explorer le cadre open source Android - 1. Okhttp Source Analysis
  4. 分布式宝典:限流 缓存 通讯,Java开发中常见的一些问题面试专题,
  5. 分享面试经历的网站,腾讯大牛教你自己写Java框架!
  6. Expliquer les six principes de base du modèle de conception par des exemples réels
  7. Site Web pour partager vos expériences d'entrevue, Tencent Bull vous apprend à écrire votre propre cadre Java!
  8. Dictionnaire distribué: communication de cache limitée par le courant, sujets d'entrevue pour certaines questions courantes dans le développement Java,
  9. Another uncle circle man is angry! The high-quality acting skills make people admire and achieve the highlight of the ending of spring in Jade House
  10. 10. MySQL database import, export and authorization
  11. 9. MySQL data query
  12. 8. MySQL data operation DML
  13. 7. MySQL database table engine and character set
  14. 分享面試經曆的網站,騰訊大牛教你自己寫Java框架!
  15. Les points de connaissance de Java Real - time Video Download, Byte Jumping Java R & D post ont été divulgués à l'intérieur.
  16. Introduction au JavaScript chapitre 15 (objets, clairvoyance)
  17. 前方高能,Java程序员最大的悲哀是什么?
  18. 别再说你不会JVM性能监控和调优了,2021华为Java高级面试题及答案,
  19. Tencent private cloud MySQL solution tdsql
  20. 前方高能,Java程序員最大的悲哀是什麼?
  21. Quelle est la plus grande tristesse des programmeurs Java à l'avenir?
  22. 15 useful cron work examples commonly used by Senior Linux system administrators
  23. Ne dites pas que vous ne pouvez pas surveiller et ajuster les performances JVM, 2021 Huawei Java Advanced interview Questions and Answers,
  24. 別再說你不會JVM性能監控和調優了,2021華為Java高級面試題及答案,
  25. 十多家大厂Java面试真题锦集干货整理,Java开发者该学习哪些东西提高竞争力?
  26. 十分钟带你回顾Spring常问的知识点,35岁老年程序员的绝地翻身之路,
  27. 区区一个SpringBoot问题就被干趴下了,看完这一篇就够了!
  28. K8s gestion des ressources (opérations de base)
  29. Java and cloud native dating
  30. 區區一個SpringBoot問題就被幹趴下了,看完這一篇就够了!
  31. Un problème de démarrage de printemps dans le district a été séché, et c'est assez!
  32. Dix minutes pour vous faire passer en revue les points de connaissance que Spring demande souvent, le chemin du retour Jedi d'un programmeur âgé de 35 ans,
  33. Plus d'une douzaine de grandes usines Java interview vrai sujet brocade collection de marchandises sèches, les développeurs Java devraient apprendre ce qui améliore la compétitivité?
  34. 十分鐘帶你回顧Spring常問的知識點,35歲老年程序員的絕地翻身之路,
  35. Guide de route d'apprentissage Java, redis a plusieurs types de données?
  36. 华为Java高级工程师面试题,字节跳动上千道精选面试题还不刷起来!
  37. 华为Java面试题目,腾讯Java开发面试记录,
  38. Propriétés et méthodes des objets Array en javascript!,Pseudo - classes et pseudo - éléments pour CSS
  39. Design pattern -- agent pattern
  40. 華為Java面試題目,騰訊Java開發面試記錄,
  41. Huawei Java interview title, Tencent Java Development interview record,
  42. Huawei Java Senior Engineer interview question, Byte Jumping thousand Selected Interview Question is still not Brushed!
  43. 双非本科字节跳动Java面试题分享,一篇文章教你搞定计算机网络面试,
  44. 又到一年金三银四,2021最新Java笔试题及答案,
  45. Huawei Finance and Economics 2021 Spring Recruitment interview, what is distributed Lock?Pourquoi utiliser des serrures distribuées?
  46. Un an plus tard, Golden, Silver, Silver, and Silver, 2021, the latest Java written Examination Questions and Answers,
  47. Partage de questions d'entrevue Java à double saut d'octets non - premier cycle, un article vous apprend à gérer l'entrevue réseau informatique,
  48. Computer graduation project java online voting system based on SSM
  49. K8s gestion des ressources (opérations de base)
  50. 又到一年金三銀四,2021最新Java筆試題及答案,
  51. Collection de code de base JavaScript (1)
  52. Vérification des permissions d'interface pour le démarrage du printemps à l'aide d'annotations personnalisées AOP +.
  53. Vérification des permissions d'interface pour le démarrage du printemps à l'aide d'annotations personnalisées AOP +.
  54. Cloud Security Daily 210914: Red Hat Jboss Middleware Platform found important Security Vulnerability and needs to be upgraded as soon as possible
  55. 吐血整理,腾讯团队实力打造spring入门教程,
  56. 史上最全的微服务专业术语面试50问,字节跳动Java岗经典面试真题,
  57. Absolument!C'est l'analyse la plus détaillée du code source de hashtap que j'ai jamais vu!
  58. Computer graduation project Java logistics order management system of logistics company based on SSM
  59. Talk about Kafka: source code analysis of producer
  60. [springboot2 starts from 0] development tips - Lombok, devtools, spring initailizr