@TestConfiguration clashing with non-test config
See original GitHub issueI’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
Issue Analytics
- State:
- Created 6 years ago
- Comments:17 (9 by maintainers)
Top Results From Across the Web
Spring Boot: @TestConfiguration Not Overriding Bean During ...
While trying to debug this I set a breakpoint inside each method as well as the constructor of the test config class. The...
Read more >Testing with Spring Boot's @TestConfiguration Annotation
We will use this project to create our service class and bean configurations and then write tests using the @TestConfiguration annotation.
Read more >Change Log — PySys v2.1 documentation - GitHub Pages
If you need to get a property whose name clashes with a built-in member, use pysys.config.project.Project.properties .
Read more >Spring Boot - Using @TestConfiguration to define beans for tests
In Spring Boot, @TestConfiguration annotation can be used to define/override beans for unit tests. @TestConfiguration vs @Configuration.
Read more >API Reference — pytest documentation
They help to inspect a test function and to generate tests according to test configuration or values specified in the class or module...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@snicoll I think things have always been that way with Gradle in Eclipse. It works in IntelliJ IDEA as 2016.1 introduced support for each source set being a separate module. There’s an open Buildship issue to do something equivalent in Eclipse.
@RobMaskell I realised I’d used the same link twice shortly after I made the comment and edited it. The second link should be correct now.