Importing Spring Framework in groovyConsole throws error

188 Views Asked by At

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?

1

There are 1 best solutions below

0
Opal On BEST ANSWER

For @Controller annotation you need to import:

import org.springframework.stereotype.*