我一直在使用编译时编织一段时间来将一些弹簧组件放入 Hibernate Search FieldBridge:
@Configurable
public class MultiLingualClassBridge implements FieldBridge,ParameterizedBridge {
@Inject
MessageSource messages;
该方面似乎正确编织(我反编译了要检查的类)但是,在运行时, MessageSource 没有被注入。
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<phase>process-classes</phase>
<goals>
<goal>compile</goal>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>${aspectj.version}</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<version>${aspectj.version}</version>
</dependency>
</dependencies>
<configuration>
<source>1.6</source>
<target>1.6</target>
<verbose>true</verbose>
<complianceLevel>1.6</complianceLevel>
<encoding>UTF-8</encoding>
<showWeaveInfo>true</showWeaveInfo>
<forceAjcCompile>true</forceAjcCompile>
<aspectLibraries>
<aspectLibrary>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
</aspectLibrary>
</aspectLibraries>
<weaveDirectories>
<weaveDirectory>${project.build.directory}/unwoven-classes</weaveDirectory>
</weaveDirectories>
</configuration>
</plugin>
我正在使用 Spring 3.1.2、Hibernate 4.2.2 和 Hibernate Search 4.3.0。我将 aspectj 从 1.6.11 升级到 1.7.2 无济于事。降级 Hibernate 似乎没有任何效果。同样的事情发生在 Tomcat 6 和 7 上。
<context:spring-configured />
<context:annotation-config/>
<context:component-scan
base-package="nl.project"/>
反编译的类(我尝试切换到注入 setMethod)
@Configurable
public class MultiLingualClassBridge
implements FieldBridge, ParameterizedBridge, ConfigurableObject
{
MessageSource messages;
static
{
ajc$preClinit();
}
public MultiLingualClassBridge()
{
JoinPoint localJoinPoint2 = Factory.makeJP(ajc$tjp_1, this, this); JoinPoint localJoinPoint1 = Factory.makeJP(ajc$tjp_0, this, this); if ((this != null) && (getClass().isAnnotationPresent(Configurable.class)) && (AnnotationBeanConfigurerAspect.ajc$if$bb0((Configurable)getClass().getAnnotation(Configurable.class)))) AnnotationBeanConfigurerAspect.aspectOf().ajc$before$org_springframework_beans_factory_aspectj_AbstractDependencyInjectionAspect$1$e854fa65(this); if ((this != null) && (getClass().isAnnotationPresent(Configurable.class)) && ((this == null) || (!getClass().isAnnotationPresent(Configurable.class)) || (!AnnotationBeanConfigurerAspect.ajc$if$bb0((Configurable)getClass().getAnnotation(Configurable.class)))) && (AbstractDependencyInjectionAspect.ajc$if$6f1(localJoinPoint1))) AnnotationBeanConfigurerAspect.aspectOf().ajc$afterReturning$org_springframework_beans_factory_aspectj_AbstractDependencyInjectionAspect$2$1ea6722c(this);
if ((!AnnotationBeanConfigurerAspect.ajc$if$bb0((Configurable)getClass().getAnnotation(Configurable.class))) && (AbstractDependencyInjectionAspect.ajc$if$6f1(localJoinPoint2))) AnnotationBeanConfigurerAspect.aspectOf().ajc$afterReturning$org_springframework_beans_factory_aspectj_AbstractDependencyInjectionAspect$2$1ea6722c(this);
}
@Inject
public void setMessages(MessageSource messages)
{
this.messages = messages;
log.info("MessageSource successfully registered");
}
我已经尝试了很多东西,但现在我已经没有办法让它发挥作用了。有什么建议么?
亲切的问候,马克