Answer the question
In order to leave comments, you need to log in
Why doesn't @Transactional work when creating a spring context via GenericXmlApplicationContext?
There is a class
@Repository
@Transactional(readOnly = true)
public class JpaAssetsRepository implements AssetsRepository {
@Override
public boolean save(List<Assets> assets) {
return false;
}
}
public class MainTest {
public static void main(String[] args) {
try (GenericXmlApplicationContext appCtx = new GenericXmlApplicationContext()) {
appCtx.load("spring/spring-app.xml", "spring/spring-db.xml");
appCtx.refresh();
System.out.println("Bean definition names: " + Arrays.toString(appCtx.getBeanDefinitionNames()));
JpaAssetsRepository rep3 = appCtx.getBean(JpaAssetsRepository.class);
rep3.save();
}
}
}
<context:annotation-config/>
<tx:annotation-driven/>
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"
p:entityManagerFactory-ref="entityManagerFactory"/>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question