私は現在、JPAとQueryDSLを使用するApache Karafで動作するOSGiアプリケーションを開発中です。OSGiとSpringデータを統合することは可能ですか?
現在のアプローチではなく、QueryDSLでSpringデータを使用できるかどうか疑問に思っていました。
これは、Springリポジトリが非常に便利であり、NoSQLデータベースへのアクセス用のテンプレートを将来的に役立つと感じているからです。
私はOSGiでWebコンテキストなしで通常のSpringアプリケーションを起動しようとしましたが、applicationContext.xmlまたはApplicationContext.classをロードしようとするとClassNoutFoundExceptionが発生します。
私はスプリングDMを廃止して使用したくないです。
基本的に、この統合を試みる理由はSpringリポジトリのためですが、これが必要でないと思われる場合は教えてください。これを実現する方法や、これを克服することが大丈夫かどうかに関する情報は歓迎する以上のものです。
は
いただきありがとうございます更新
私はorg.eclipse.gemini.blueprint.context.support.OsgiBundleXmlApplicationContext
とアプリケーションコンテキストを開始することにより、スプリングを動作させることができました。 applicationContextはサービスとしてOSGiにエクスポートされ、必要なすべてのBeanを呼び出すことができます。
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#0' defined in URL [bundle://251.13:0/META-INF/spring/applicationContext.xml]: Initialization of bean failed; nested exception is java.lang.IllegalStateException: No persistence exception translators found in bean factory. Cannot perform exception translation.
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)[185:org.springframework.beans:3.1.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)[185:org.springframework.beans:3.1.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)[185:org.springframework.beans:3.1.4.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)[185:org.springframework.beans:3.1.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)[185:org.springframework.beans:3.1.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)[185:org.springframework.beans:3.1.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1109)[187:org.springframework.context:3.1.4.RELEASE]
at org.eclipse.gemini.blueprint.context.support.AbstractDelegatedExecutionApplicationContext.registerBeanPostProcessors(AbstractDelegatedExecutionApplicationContext.java:502)[193:org.eclipse.gemini.blueprint.core:1.0.0.RELEASE]
at org.eclipse.gemini.blueprint.context.support.AbstractDelegatedExecutionApplicationContext.registerBeanPostProcessors(AbstractDelegatedExecutionApplicationContext.java:451)[193:org.eclipse.gemini.blueprint.core:1.0.0.RELEASE]
at org.eclipse.gemini.blueprint.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:306)[193:org.eclipse.gemini.blueprint.core:1.0.0.RELEASE]
at org.eclipse.gemini.blueprint.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)[193:org.eclipse.gemini.blueprint.core:1.0.0.RELEASE]
at org.eclipse.gemini.blueprint.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:290)[193:org.eclipse.gemini.blueprint.core:1.0.0.RELEASE]
at org.eclipse.gemini.blueprint.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:137)[194:org.eclipse.gemini.blueprint.extender:1.0.0.RELEASE]
at java.lang.Thread.run(Thread.java:662)[:1.6.0_37]
Caused by: java.lang.IllegalStateException: No persistence exception translators found in bean factory. Cannot perform exception translation.
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.detectPersistenceExceptionTranslators(PersistenceExceptionTranslationInterceptor.java:142)[195:org.springframework.transaction:3.1.4.RELEASE]
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.<init>(PersistenceExceptionTranslationInterceptor.java:79)[195:org.springframework.transaction:3.1.4.RELEASE]
at org.springframework.dao.annotation.PersistenceExceptionTranslationAdvisor.<init>(PersistenceExceptionTranslationAdvisor.java:70)[195:org.springframework.transaction:3.1.4.RELEASE]
at org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor.setBeanFactory(PersistenceExceptionTranslationPostProcessor.java:103)[195:org.springframework.transaction:3.1.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeAwareMethods(AbstractAutowireCapableBeanFactory.java:1475)[185:org.springframework.beans:3.1.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1443)[185:org.springframework.beans:3.1.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)[185:org.springframework.beans:3.1.4.RELEASE]
私はOpenJPAのを使用しているJPAプロバイダとして:
私が今抱えている問題は、私は<jpa:repositories base-package="x.y.z" />
を宣言するとき、私は次の例外を取得していることです。 entityManagerFactoryは、青写真を使用して取得できるサービスです。私は<jpa:repositories base-package="x.y.z" />
でそれを参照する必要があると思うが、applicationContext.xmlは青写真ではなく春に読み込まれるので、どうすればいいですか?
私は本当に正しい方向へのヒントを感謝します。 、使用 -
は
春のDMが中止されていないのOSGiエンタープライズ仕様の完全なJPAの章のためのhibernate-osgi-adapterを書きました。 「Gemini Blueprint」に改名されました。 –
しかし、現在はspring-dmの構文とは若干異なる青写真ですので、「中止」と呼ぶかもしれません。私はまだ特定のシナリオでそれを使用しています... :) –
ありがとうAchim Nierbeck。あなたの答えのおかげで、私はSpringのDMクラスがSpringの仕事を作ったことがわかりました。私も私の答えを更新しました。 Apache KarafとSpring Dataを統合することについて何か知っていれば、本当に感謝しています。もう一度ありがとう:) – Marius