Java example development tutorial: SpringBoot development case

Recently, I am doing mail sending services. Normally SpringBoot integrates mail is very convenient, but there are new requirements: A request is sent by mailbox C, and B request is sent by mailbox D. That is to say, we need to configure two sets of sending services. .

Single instance

First, let's look at the configuration of a single service:
Insert picture description here

Don't worry about the others, we just need to inject the following when we use it:
Insert picture description here

If you are interested in how to load the configuration and initialize, you can understand the principle of spring-boot-autoconfigure.

Multi-instance

Since mail does not provide multiple data sources like a database, here we can only obtain it manually:
Insert picture description here

Here, by the way, a small feature, how to customize the display of the sender's name when sending mail:
Insert picture description here

Finally, when we use it, we only need to use different senders according to different requests.

The above is the content of "Java Example Development Tutorial: SpringBoot Development Case" introduced by Xiaoqian, I hope it will be helpful to everyone. For more Java latest information, you can follow me, share Java technology knowledge and industry information every day, so that you have a clear understanding of the knowledge that Java development needs to master, and can quickly get started with Java development.

Guess you like

Origin blog.csdn.net/xiaoxijinger/article/details/114921455