1
我有一個駱駝項目,我想使用Hibernate和支持事務。Maven的依賴駱駝 - 春 - 休眠項目
我有以下依賴關係,這與駱駝休眠組件工作正常。
<properties>
<mysql.connector.version>5.1.31</mysql.connector.version>
<camel.version>2.16.1</camel.version>
<org.springframework.version>4.2.4.RELEASE</org.springframework.version>
<mysql.connector.version>5.1.31</mysql.connector.version>
</properties>
<dependencies>
<dependency>
<groupId>commons-pool</groupId>
<artifactId>commons-pool</artifactId>
<version>1.6</version>
</dependency>
<!-- camel -->
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
<version>${camel.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring</artifactId>
<version>${camel.version}</version>
</dependency>
<!-- Active MQ -->
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-all</artifactId>
<version>5.10.0</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-jms</artifactId>
<version>${camel.version}</version>
</dependency>
<dependency>
<groupId>org.apache.xbean</groupId>
<artifactId>xbean-spring</artifactId>
<version>3.18</version>
</dependency>
<dependency>
<groupId>org.apache-extras.camel-extra</groupId>
<artifactId>camel-hibernate</artifactId>
<version>2.14.1</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-dbcp2</artifactId>
<version>2.1.1</version>
</dependency>
<!-- use spring TX -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.connector.version}</version>
</dependency>
</dependencies>
現在,我要打電話的路線
<to uri="bean:accountService?method=findByType(2)"/>
添加到服務豆,我得到
「無法獲得交易同步會話當前線程的」
我試過添加<tx:annotation-driven/>
並添加了這些de pendencies
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${org.springframework.version}</version>
</dependency>
所以現在,我越來越:
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.apache.camel.maven.RunMojo$1.run(RunMojo.java:457)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NoSuchMethodError: org.springframework.beans.factory.config.ConfigurableListableBeanFactory.clearMetadataCache()V
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:185)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:678)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:520)
at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:140)
at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:94)
at org.apache.camel.spring.Main.createDefaultApplicationContext(Main.java:205)
at org.apache.camel.spring.Main.doStart(Main.java:154)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
at org.apache.camel.main.MainSupport.run(MainSupport.java:124)
at org.apache.camel.main.MainSupport.run(MainSupport.java:343)
at org.apache.camel.spring.Main.main(Main.java:87)
我認爲這是關係到Maven依賴。請幫我解決這個問題。
ActiveMQ 5.10可能使用Spring 3,而不是Spring 4.我認爲在彈簧庫之間有一個衝突的版本。使用'mvn dependency:tree -Dverbose'來查看依賴關係樹,並向Spring 3庫添加一個排除。更重要的是,您應該使用ActiveMQ的v5.13 –
將彈簧版本更改爲4.1.8.RELEASE(這是駱駝使用的版本)並且它正在工作。因此,似乎有一些我沒有明確聲明的庫的Spring版本存在衝突。如果我想升級到更新的Spring,你能否建議如何找到應該被覆蓋的相關依賴項? –
如果你使用'mvn dependency:tree',你會看到哪些庫對spring有依賴關係並且依賴關係的版本 –