我正在迁移一个使用 xml 映射到 spring boot (.java 文件) 的项目
我该怎么办?下面是 jackrabbit 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"/>
最佳答案
首先,您应该使用 @Configuration 创建一个配置类文件,并使用 @ImportResource 导入 .xml 文件,如下所示:-
@Configuration
@ImportResource("classpath:dmsRepository.xml")
public class JackRabbitRepository {
}
然后您必须将资源内容保留在 server.xml 文件中,因为它在您当前的 xml 中不起作用。之后 JackRabbit 的配置就完成了。 然后在 DMS 中执行您想要执行的操作。
关于xml - 将xml的配置改为spring boot,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37561277/