question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

@TestConfiguration clashing with non-test config

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:17 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
wilkinsonacommented, May 8, 2017

@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.

1reaction
wilkinsonacommented, May 8, 2017

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found