Skip to content

Grails app should auto import spring component #12389

@rainboyan

Description

@rainboyan

Expected Behavior

It should see demo

When add @ComponentScan to Application, it run success.
Grails support grails.spring.bean.packages, but I think this config for external packages, Grails App should auto scan package where Application belong.

import org.springframework.context.annotation.ComponentScan

@CompileStatic
@ComponentScan
class Application extends GrailsAutoConfiguration {
    static void main(String[] args) {
        GrailsApp.run(Application, args)
    }
}

Actual Behaviour

Class: java.lang.NullPointerException
Message: null
Caused by: Cannot get property 'name' on null object

Steps To Reproduce

grails create-app com.rainboyan.demo.app-component-auto-scan-issue
grails run-app

open http://localhost:8080/demo/index

When render demo, it's OK!

Environment Information

Grails Version: 5.1.2
JVM Version: 11.0.14
OS: MacOS 11.6.4 M1

Example Application

https://github.com/rainboyan/grails-app-component-auto-scan-issue

Version

5.1.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions