2016-06-01 177 views
2

我遷移其用於映射XML春季啓動(java文件)更改配置到春季啓動

我應該如何去做一個項目?下面是兔崽子xml配置...

<bean id="repository" class="org.springframework.jndi.JndiObjectFactoryBean"> 
    <property name="jndiName" value="java:comp/env/jcr/myRepository"/> 
</bean> 

<bean id="jcrSessionFactory" class="org.springmodules.jcr.JcrSessionFactory"> 
    <property name="repository" ref="repository" /> 
    <property name="credentials"> 
     <bean class="javax.jcr.SimpleCredentials"> 
     <constructor-arg index="0" value="admin" /> 
     <!-- create the credentials using a bean factory --> 
     <constructor-arg index="1"> 
      <bean factory-bean="password" factory-method="toCharArray" /> 
     </constructor-arg> 
     </bean> 
    </property> 
</bean> 

    <!-- create the password to return it as a char[] --> 
    <bean id="password" class="java.lang.String"> 
    <constructor-arg index="0" value="admin" /> 
    </bean> 

    <bean id="jcrTemplate" class="org.springmodules.jcr.JcrTemplate"> 
    <property name="sessionFactory" ref="jcrSessionFactory" /> 
    <property name="allowCreate" value="true" /> 
    </bean> 

<Resource name="jcr/myRepository" 
    auth="Container" 
    type="javax.jcr.Repository" 
    factory="org.apache.jackrabbit.core.jndi.BindableRepositoryFactory" 
    configFilePath="D:/DMSRepo/repositoryFactlive.xml" 
    repHomeDir="D:/DMSRepo/factlivetrialVersion2/repo"/> 
+0

Small int'class'引用一個類...你可以用'new'創建這些東西。從那開始。 –

回答

2

首先,你應該使用@Configuration使用@ImportResource這樣創建一個配置類文件,並導入.xml文件: -

@Configuration 
@ImportResource("classpath:dmsRepository.xml") 
public class JackRabbitRepository { 

} 

然後你必須保持你的資源內容在server.xml文件中,它不會在你當前的xml中工作。在此之後,您完成了JackRabbit的配置。 然後在DMS中做你想做的事情。