Is it a bad practice for a spring project jar project to provide a bean configuration file?

If you have a library containing Spring beans that needs to be linked together before the application can use them, does it make sense to include any bean configuration file (for example, the META-INF directory) in the JAR? The idea is to give the application the ability to import this into its Spring wizard context configuration.

There may be several ways to connect these beans, so I can provide a bean configuration file for each of the standard ways that you usually bundle them together.

Or can I get the application to directly connect them?

If this helps, the features of my problem are related to the library I created to encapsulate the product preservation layer. It contains Service, DAO and beans model. DAO implementations currently use Hibernate (this probably won't change). Some DAO implementations require different types of beans strategies into which they are embedded (database encryption logic), depending on the type of database we are deploying (MySQL vs SQL Server, etc.). Therefore, we have potentially several different configuration scenarios. I could also provide a datasource bean configuration, relying on application-level property substitution to enter all the data needed for the data source.

Thanks for your input!

+4
source share
1 answer

In this case, it is recommended to provide some beans files either as examples for documentation purposes, or as complete files, ready to be included in a wider context.

If your beans' wiring can become complicated, you do not have to leave it completely up to the library client to understand it.

In fact, it is rather the task of documentation and education.

+3
source

All Articles