Bil*_*hah 6 spring gradle spring-data
我有一个项目在一个项目中进行数据访问,并在另一个项目中用作springjar.我用gradle maven-publish插件创建了jar .我在我的其他项目测试用例中初始化了这个Jar
@ContextConfiguration(locations = {"classpath*:spring-config.xml"})
@Transactional
public class TenantProvisioningManagerTest extends AbstractTestNGSpringContextTests {}
Run Code Online (Sandbox Code Playgroud)
类,其中Repository正在使用.我这样用过
public class TenantProvisioningManager {
private static final Logger logger = LogManager.getLogger(TenantProvisioningManager.class);
@Autowired
TProductRepository tProductRepository;
}
Run Code Online (Sandbox Code Playgroud)
存储库在null这里.如何在这个单独的项目中从其他jar初始化存储库?
spring-config.xml:
<?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:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/data/jpa
http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
">
<context:property-placeholder
location="file://#{systemEnvironment['GRADLE_USER_HOME']}/gradle.properties"/>
<!-- the base package for spring data jpa repository interfaces -->
<jpa:repositories base-package="com.asklytics.dao.repos" />
<!-- Enable the component scan (auto wiring etc) for the following package -->
<context:component-scan base-package="com.asklytics" />
<!-- Make sure the following is specified to enable transaction -->
<tx:annotation-driven />
<bean class="org.springframework.orm.jpa.JpaTransactionManager" id="transactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
<!-- This defines the entity manager factory with some custom properties -->
<bean id='entityManagerFactory' class='org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean'>
<property name="persistenceUnitName" value="persitanceUnit"/>
<property name='dataSource' ref='dataSource' />
</bean>
<bean id='dataSource' class='org.springframework.jdbc.datasource.DriverManagerDataSource'>
<property name='driverClassName' value='com.mysql.jdbc.Driver' />
<property name='url' value="${awsCamelDbUrl}" />
<property name='username' value="${awsCamelDbUsername}" />
<property name='password' value="${awsCamelDbPassword}" />
</bean>
Run Code Online (Sandbox Code Playgroud)
spring-config.xml而TProductRepository在其他的项目,而TenantProvisioningManager在单独的项目.
| 归档时间: |
|
| 查看次数: |
345 次 |
| 最近记录: |