Skip to content

Injecting prototypes into tests using @Resource appears to be broken [SPR-9580] #14214

@spring-projects-issues

Description

@spring-projects-issues

Tom Ziemer opened SPR-9580 and commented

When injecting a prototype bean into a test derived from AbstractJUnit4SpringContextTests using @Resource, it seems that the bean is only created once.
Prior to Spring 3.1.2 this was not the case, the framework provided a new instance for each test run.

As a workaround, I now use @Autowired + @Qualifier.

The attached project uses a unit test to show the problem. Changing the Spring version to 3.1.1-RELEASE (or lower) in the pom fixes the issue.


Affects: 3.1.2

Attachments:

Issue Links:

5 votes, 6 watchers

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions