Grails 3和Spring @RequestMapping


问题内容

在Grails 3中,我尝试使用spring-security-
oauth,它通过@RequestMapping提供了一些终结点,我可以在mbeans中看到已配置路径,但是任何请求始终会命中Grails并返回404。

该请求似乎从未命中spring-security-oauth lib配置的任何端点。无论如何,要确保请求能够到达jar中的端点?


问题答案:

为了确保使用Java配置在Grails
3应用程序中显示由@RequestMapping配置的端点,您必须在Application.groovy中使用以下设置

@ComponentScan("my.org.config")
class Application extends GrailsAutoConfiguration {
    static void main(String[] args) {
        GrailsApp.run(Application)
    }
}

不要通过以下方式使用application.yml:

grails:
    profile: web
    spring:
        bean:
            packages:
                - my.org.config

虽然将使用@RequestMapping拾取bean,但是将无法访问。