我有一个在模块中声明的数据库。我有一个核心业务逻辑模块,我需要在其中公开数据库。我将数据库定义为单例和服务。但是,我还需要从核心业务逻辑模块访问数据库。该服务的工作,但我无法从核心引用 tkn 数据库。
我需要在fleet.mt1.core 模块中引用在模块fleet.mt1.dataserviceimpl 中定义的TKN 数据库。
想知道如何做到这一点?如果骆驼蓝图/春天有办法可以做到这一点???
车队.mt1.dataserviceimpl
<cm:property-placeholder persistent-id="com.ge.digital.fleet.dataservice.impl"/>
<!-- Ensure that only one instance of a class pdxDb is created -->
<!-- Provide a global point of access to the object -->
<bean class="com.ge.digital.fleet.dataservice.impl.db.PDXDatabase"
id="pdxDb" scope="singleton"/>
<bean class="com.ge.digital.fleet.dataservice.impl.db.TKNDatabase"
id="tknDb" scope="singleton"/>
<!-- PDX Data Service Implementation -->
<bean
class="com.ge.digital.fleet.dataservice.impl.PDXDataServiceImpl" id="pdxDataService">
<property name="pdxDatabase" ref="pdxDb"/>
</bean>
<bean
class="com.ge.digital.fleet.dataservice.impl.TKNDataServiceImpl" id="tknDataService">
<property name="tknDatabase" ref="tknDb"/>
</bean>
<!-- PDX Data Service Registration -->
<service depends-on="pdxDb"
interface="com.ge.digital.fleet.dataservice.PDXDataService" ref="pdxDataService"/>
<service depends-on="tknDb"
interface="com.ge.digital.fleet.dataservice.TKNDataService" ref="tknDataService"/>
<bean
class="com.ge.digital.fleet.dataservice.impl.processor.ReplicatedDataProcessor" id="replicatedDataProcessor">
<property name="pdxDatabase" ref="pdxDb"/>
</bean>
<bean
class="com.ge.digital.fleet.dataservice.impl.filter.FTPFileFilter" id="ftpFileFilter"/>
<!-- properties found in com.ge.digital.fleet.dataservice.impl.cfg under etc -->
<bean
class="com.ge.digital.fleet.dataservice.impl.route.ReplicatedDataRouteBuilder"
depends-on="ftpFileFilter" id="replicatedDataRouteBuilder">
<property name="transportSftp" value="${transportSftp}"/>
<property name="transportFs" value="${transportFs}"/>
<property name="username" value="${username}"/>
<property name="host" value="${host}"/>
<property name="port" value="${port}"/>
<property name="pathSftp" value="${pathSftp}"/>
<property name="pathFs" value="${pathFs}"/>
<property name="password" value="${password}"/>
<property name="moveToPath" value="${moveToPath}"/>
<property name="fileArchive" value="${fileArchive}"/>
<property name="readLockFile" value="${readLockFile}"/>
<property name="ftpFileFilter" value="ftpFileFilter"/>
</bean>
<camelContext id="com.ge.digital.fleet.dataServiceImplCamelContext"
trace="false" xmlns="http://camel.apache.org/schema/blueprint">
<routeBuilder ref="replicatedDataRouteBuilder"/>
</camelContext>
</blueprint>
车队.mt1.core
<reference id="pdxDataService" interface="com.ge.digital.fleet.dataservice.PDXDataService"/>
<bean
class="com.ge.digital.fleet.core.processors.DbAvailableProcessor" id="dbAvailableProcessor">
<property name="dataService" ref="pdxDataService"/>
</bean>
<reference id="tknDataService" interface="com.ge.digital.fleet.dataservice.TKNDataService"/>
<bean class="com.ge.digital.fleet.dataservice.impl.db.TKNDatabase"
id="tknDb" scope="singleton"/>
<bean
class="com.ge.digital.fleet.core.processors.AccessKeyMarsheler" id="accessKeyMarsheler">
<property name="tknDatabase" ref="tknDb"/>
</bean>
这是错误的,我知道,这是我的问题,如何或可以在核心模块中引用它?
<bean class="com.ge.digital.fleet.dataservice.impl.db.TKNDatabase"
id="tknDb" scope="singleton"/>
谢谢你的帮助!我正在为此苦苦挣扎。我尝试过引用 Bean、Class 但当然,这是非法的语法。
我正在为服务开发另一个接口以跨模块访问它,我想我希望有一种方法可以在 Spring 中执行此操作,作为引用或依赖项或其他东西。