Service beans not auto-injecting into other service beans without @Autowired
- Dominant language
- Groovy
- Stars
- 2.9k
- Forks
- 975
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 92
Description
### 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 `InvocationTargetException`s 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](https://github.com/user-attachments/files/31242426/build.gradle.txt)
------------------------------------------------------------
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
Contributor guide
Research direction
Start with the linked build.gradle and compare service-bean injection behavior between Grails 8.0.0-M3 and M5. Reproduce the issue with service fields lacking @Autowired, then trace the service-bean wiring entry point; done means dependent service fields are populated without field annotations, with a regression test covering the behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- groovy
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100