几周前,我开发了一个基于 Alfresco 3.4.14 的 AMP。在那个模块中,我创建了一些定制服务。其中一项服务用于管理用户,并提供了一种创建新用户的方法:
public NodeRef createUser(<my_parameters>) {
..........................
..........................
HashMap<QName, Serializable> properties = new HashMap<QName, Serializable>();
properties.put(ContentModel.PROP_USERNAME, username);
properties.put(ContentModel.PROP_PASSWORD, password);
..........................
..........................
NodeRef person = personService.createPerson(properties);
return person;
}
所有服务都在露天上下文文件中定义:
<?xml version='1.0' encoding='UTF-8'?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<bean id="customUserService" class="com.mycustom.service.impl.CustomUsersServiceImpl">
<property name="personService" ref="PersonService"/>
<property name="nodeService" ref="NodeService"/>
</bean>
<bean id="customProjectsService" class="com.mycustom.service.impl.CustomProjectsServiceImpl">
<property name="searchService" ref="SearchService"/>
<property name="nodeService" ref="NodeService"/>
</bean>
</beans>
一切正常。我能够创建用户,执行我的其他定制服务......直到这里完美!!!!!!!!!该应用程序运行正常。
几天前,我们决定开始使用spring注解,而不是定义上下文中的所有bean:
package com.mycustom.service.impl;
@Service("customUsersService")
public class CustomUsersServiceImpl implements CustomUsersService {
@Override
public NodeRef createUser(<my_parameters>) {
}
}
在上下文文件中,使用 spring 组件扫描:
<?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:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:annotation-config/>
<context:component-scan base-package="com.mycustom.service" />
</beans>
所有服务都正常工作,应用程序看起来也正常工作。我们很高兴,因为我们可以使用注释解耦我们的应用程序。
BUTTTTTTTTTTTT,当我尝试通过资源管理器或通过应用程序创建用户时,我得到了同样的错误:Failed to create Person due to error: xxxxxxx beforeCreateNode: use PersonService to create person