---
title: "The main advantage of  using the Spring DSL"
author: "boogie"
date: "2008-05-26T10:56:09Z"
tags: []
slug: "the-main-advantage-of-using-the-spring-dsl"
draft: false
lastmod: "2008-05-26T10:56:09Z"
id: 196918
url: "https://boogie.iteye.com/blog/196918"
---

The main advantage of using the Spring DSL is that you can now mix logic in within your bean definitions, for example based on the [environment](http://grails.org/doc/1.0.x/guide/single.html#3.2%20Environments) :

```
import grails.util.*

beans {
	switch(GrailsUtil.environment) {
		case "production":
			myBean(my.company.MyBeanImpl) {
				bookService = ref("bookService")
			}
                break 
                case "development": 
                        myBean(my.company.mock.MockImpl) { 
                               bookService = ref("bookService") 
                        }
                break 
        } 
}
```