Create spring beans using YAML

Spring highly adopted annotation based configuration and it is happily accepted by developer communities and why not, no one wants to struggle with XML tags but that’s not enough somewhere we still miss XML configuration or you can say external file configuration as powerful as XML configuration. especially when we write an application that has to alter behaviors without compilation.

But still writing an XML configuration is not readable and not easily understandable for beginners, so I’ve written experimental plugins for spring boot that convert YAML definition to Spring Beans.

here is an example of bean definition in XML and same in YAML.

Spring-beans.xml

Screen Shot 2017-11-04 at 6.45.07 PM

Spring-beans.yaml

Screen Shot 2017-11-04 at 6.44.14 PM

above code snippet, you can see a line of code and readability, let jump in a code example.

below code snippet, only need to add annotation “@ImportYamlResource” that will work same as “@ImportResource”

Screen Shot 2017-11-05 at 10.38.22 AM

below an example link, you can check out a project from git

yaml-beans-example

download library 

 

Note ->  YAML-spring-beans is a just experimental library, still there are lots of features not included

feedback will be much appreciated 🙂

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s