ozimov / spring-boot-email-tools

A set of services and tools for sending emails in a Spring Boot 1.5.x application using a Template Engine

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add @EnableEmailTools annotation

C-h-e-r-r-y opened this issue · comments

Most of spring boot libraries has @Enable...Configuration annotation which can simply import you own @Configuration class. So instead of

@ComponentScan(basePackages = {"com.myapplication", "it.ozimov.springboot"})

It can be like that (not tested!)

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@Import(EmailToolsConfiguration.class)
@interface EnableEmailTools  {}

@Configuration
@ComponentScan("it.ozimov.springboot")
public class EmailToolsConfiguration {}

It gives for you the following:

  1. Decouples client logic from it.ozimov.springboot, you can easyly move any components, only keep annotation in same package.
  2. Your spring boot library looks more in standart way (e.g. modern, cool, new!!! ;)). It is easy to type "EE" in IDE to see "EnableEmailTools" in auto complete then google library name and go to readme file.

I agree. There is a lot to do. This is definitely one worth to be implemented.
Thanks for the suggestion. If you want to open a PR with the change I'll be happy to merge it. Otherwise I'll schedule this feature for release 0.5.0 (next March I guess).

@C-h-e-r-r-y thanks again for pointing out that elegant solution. I created a pull request, and it works exactly as you suggested. I'm sorry you did not made a pull request, It was nice to credit you as a contributor (GitHub does that by reading the commits). You are still free to pickup my PR and do some addition, even cosmetic changes. I'm not going to merge before than 24 hours.