Skip to content

@TestConfiguration clashing with non-test config #9126

@RobMaskell

Description

@RobMaskell

I'm trying to have different config for running a spring boot 1.5.3 app in STS (and eventually prod) but have different config for tests.

I read this in the docs

When placed on a top-level class, @TestConfiguration indicates that classes in src/test/java should not be picked up by scanning. You can then import that class explicitly where it is required:

Problem is that I'm getting the test config when I start the app from the STS dashboard.

Sample app here, try to start it and it complains about two beans when it wanted only one. Same behavior in 1.4.3 makes me think this must be by design so what did I do wrong?

***************************
APPLICATION FAILED TO START
***************************

Description:

Field someService in com.example.TestController required a single bean, but 2 were found:
	- getSomeTestService: defined by method 'getSomeTestService' in class path resource [com/example/TestConfig.class]
	- getSomeService: defined by method 'getSomeService' in com.example.TestconfigApplication

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: invalidAn issue that we don't feel is valid

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions