Die Annotation einer Methode in der implementierenden Klasse mit @Transactional
löst diese Ausnahme aus.Eine Methode mit @Transactional Ursachen annotieren "Keine eindeutige Bean des Typs ist definiert: erwartete einzelne Bean, aber 0 gefunden"
Spring-Konfiguration:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<bean id="benchmarkManager" class="com.test.userjobmanager.UserJobManager"/>
<tx:annotation-driven transaction-manager="transactionManager" order="10"/>
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="readDataSource"/>
</bean>
<!-- other beans here -->
</beans>
Wenn ich die Bohne bin Zugriff auf wie:
JobManager jobManager = ac.getBean(UserJobManager.class);
ich habe folgendes Stacktrace:
Exception in thread "Haupt" org.springframework.beans.f actory.NoSuchBeanDefinitionException: Nein einzigartige Bohne vom Typ [com.test.userjobmanager.UserJobManager] ist definiert: Bohne erwartet, aber fand 0: bei org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean (DefaultListableBeanFactory.java: 269) bei org.springframework.context.support.AbstractApplicationContext.getBean (AbstractApplicationContext.java:1083)
Wenn ich die @Transactional
entfernen, es funktioniert gut. Ich bin mir nicht sicher, was das Problem hier ist.
@AliDehghani Transaktionsmanager Config hinzugefügt. – Viraj