How to write springboot application ？ In fact, there is a way .
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
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 .
Corresponding effective configuration , If you are interested, you can refer to the previous automatic configuration process , To analyze a wave of .
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
application.properties In the document ：
spring.banner.image.location=classpath:banner1.jpg Copy code
Start the application , Look at the effect ：
Configuration is successful .
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 .