-
Notifications
You must be signed in to change notification settings - Fork 41.7k
Closed
Description
Project using Spring Session JDBC blows up on startup with UnsatisfiedDependencyException if there is a component that attempts to inject JdbcOperations.
Steps to reproduce:
- download demo project:
$ curl https://start.spring.io/starter.tgz -d dependencies=web,jdbc,h2,session -d baseDir=demo- apply the following diff:
diff --git a/src/main/java/com/example/TestComponent.java b/src/main/java/com/example/TestComponent.java
new file mode 100644
index 0000000..077bd3b
--- /dev/null
+++ b/src/main/java/com/example/TestComponent.java
@@ -0,0 +1,10 @@
+package com.example;
+
+import org.springframework.jdbc.core.JdbcOperations;
+import org.springframework.stereotype.Component;
+
+@Component
+public class TestComponent {
+ public TestComponent(JdbcOperations jdbcOperations) {
+ }
+}
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
index e69de29..bf00c58 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -0,0 +1 @@
+spring.session.store-type=jdbcThis fails with:
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 0 of constructor in com.example.TestComponent required a single bean, but 2 were found:
- jdbcTemplate: defined by method 'jdbcTemplate' in class path resource [org/springframework/boot/autoconfigure/jdbc/JdbcTemplateAutoConfiguration.class]
- springSessionJdbcOperations: defined by method 'springSessionJdbcOperations' in class path resource [org/springframework/boot/autoconfigure/session/JdbcSessionConfiguration$SpringBootJdbcHttpSessionConfiguration.class]
Action:
Consider marking one of the beans as @Primary, updating the consumer to accept multiple beans, or using @Qualifier to identify the bean that should be consumed
Metadata
Metadata
Assignees
Labels
type: enhancementA general enhancementA general enhancement