Skip to content

Service beans not auto-injecting into other service beans without @Autowired #16177

Description

@whorvath2

Expected Behavior

Service beans that depend on other service beans shouldn't have to add @Autowired to their fields to have them injected (unless that's intended behavior; I checked the upgrade guidance this time but couldn't find anything.)

Actual Behaviour

I have a collection of service beans, some of which have other service beans as fields. The field beans were auto-injected into their enclosing services in M3, but aren't doing so in M5 (i.e., the field values are null), resulting in InvocationTargetExceptions when those field's methods are called. However, I found that adding @Autowired to the fields forces the injections. For example, here's a before:

@Service
class LicenseService {

    InvoiceService invoiceService
    ProjectUserService projectUserService
    ProjectService projectService

And here's what it looks like now, which allows the licenseService to work when (e.g.) it uses its invoiceService instance:

@Service
class LicenseService {

    @Autowired
    InvoiceService invoiceService
    @Autowired
    ProjectUserService projectUserService
    @Autowired
    ProjectService projectService

Steps To Reproduce

No response

Environment Information

build.gradle


Gradle 9.5.1

Build time: 2026-05-12 13:19:42 UTC
Revision: fd78213f09782e62ca4957f9cfd3d90c6c3f1767

Kotlin: 2.3.20
Groovy: 4.0.29
Ant: Apache Ant(TM) version 1.10.15 compiled on August 25 2024
Launcher JVM: 25.0.3 (Amazon.com Inc. 25.0.3+9-LTS)
Daemon JVM: /Users/bhorvath/.sdkman/candidates/java/25.0.3-amzn (no Daemon JVM specified, using current Java home)
OS: Mac OS X 26.6.2 aarch64

| Grails Version: 8.0.0-M5
| JVM Version: 25.0.3

Example Application

No response

Version

8.0.0-M5

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions