javaspringgroovygroovy-consolespring-groovy-config

Importing Spring Framework in groovyConsole throws error


I have a very simple Groovy script:

import org.springframework.*;

@groovy.transform.ToString()
@Controller(name="myHomeController")
class HomeController {

    String home() {

    }
}

As I use the @Controller annotation I used the menu option:

Script -> Import jars into classpath

But when compliging I receive the error:

1 compilation error:

unable to resolve class Controller ,  unable to find class for annotation
 at line: 2, column: 1

What is the correct way to use Spring Framework from the groovyConsole?


Solution

  • For @Controller annotation you need to import:

    import org.springframework.stereotype.*