org.springframework.beans.factory.BeanCreationException: Could not inject field: protected static com.services.SchedulerService com.test.SchedulerControllerTest.schedulerServiceTest; nested exception is java.lang.IllegalStateException: The field protected static com.services.SchedulerService com.test.SchedulerControllerTest.schedulerServiceTest cannot have an existing value

Searched on Google with the first line of a JAVA stack trace?

We can recommend more relevant solutions and speed up debugging when you paste your entire stack trace with the exception message. Try a sample exception.

Recommended solutions based on your search

Samebug tips

,
Expert tip

If you're using boot 1.4.x you need to modify the @springBootTest annotation to @SpringBootTest(classes = DataFlowServerConfiguration.class). 1.3.8 doesn't have this problem as well.

,
Expert tip

Spring Boot 1.4 changed their annotation system a little. Try using the @SpringBootApplication annotation for better results.

Solutions on the web

via Stack Overflow by Jayesh Mule
, 9 months ago
Could not inject field: protected static com.services.SchedulerService com.test.SchedulerControllerTest.schedulerServiceTest; nested exception is java.lang.IllegalStateException: The field protected static com.services.SchedulerService com.test.SchedulerControllerTest.schedulerServiceTest cannot have an existing value
org.springframework.beans.factory.BeanCreationException: Could not inject field: protected static com.services.SchedulerService com.test.SchedulerControllerTest.schedulerServiceTest; nested exception is java.lang.IllegalStateException: The field protected static com.services.SchedulerService com.test.SchedulerControllerTest.schedulerServiceTest cannot have an existing value
at org.springframework.boot.test.mock.mockito.MockitoPostProcessor.inject(MockitoPostProcessor.java:400)
at org.springframework.boot.test.mock.mockito.MockitoPostProcessor.inject(MockitoPostProcessor.java:393)
at org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener.injectFields(MockitoTestExecutionListener.java:73)
at org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener.injectFields(MockitoTestExecutionListener.java:62)
at org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener.prepareTestInstance(MockitoTestExecutionListener.java:49)
at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:230)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:228)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:289)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:247)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)

Users with the same issue

2 times, 4 months ago
Once, 6 months ago
7 times, 3 weeks ago
Once, 2 months ago
4 times, 11 months ago
67 more bugmates

Know the solutions? Share your knowledge to help other developers to debug faster.