我一直在使用编译时编织一段时间来将一些Spring组件放入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");
}
我已经尝试了很多东西,但现在我已经没有想法如何让它发挥作用。有什么建议吗?
亲切的问候, 马克
答案 0 :(得分:0)
这似乎可以解决问题
<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean" depends-on="org.springframework.context.config.internalBeanConfigurerAspect">