我有一个 Spring / Hibernate 应用程序。Hibernate 创建的自定义类型需要 Spring 上下文,所以我使用 Spring Aspects 来提供它。
@Configurable(preConstruction = true)
public class EncryptedStringUserType implements EnhancedUserType {
...
@EnableSpringConfigured
@EnableLoadTimeWeaving
public class RootConfiguration {
...
添加 Spring Security 后,我在 stderr 中收到了如下消息:
[AppClassLoader@14dad5dc] error can't determine implemented interfaces of missing type org.springframework.security.ldap.authentication.LdapAuthenticationProvider
when weaving type org.springframework.security.config.annotation.authentication.configurers.ldap.LdapAuthenticationProviderConfigurer
when weaving classes
when weaving
[Xlint:cantFindType]
是否可以指定应该编织的类包并避免尝试编织其他包?
解决方案
将 META-INF/aop.xml 放到资源根目录下,排除不必要的包:
<!DOCTYPE aspectj PUBLIC "-//AspectJ//DTD//EN" "http://www.eclipse.org/aspectj/dtd/aspectj.dtd">
<aspectj>
<weaver>
<exclude within="org.springframework.security.config.annotation.authentication.configurers.ldap.*"/>
<exclude within="org.springframework.security.config.annotation.web.configurers.openid.*"/>
</weaver>
</aspectj>