2014-11-06 105 views
2

我在Spring中尝试使用Spring 3.2中的AspectJ来开始我的旅程。我正在追踪书“春天在行动”。笔者使用的AspectJ通过导入AspectJ的包是这样的:但是使用Spring找不到AspectJ软件包

import org.aspectj.lang.annotation.Aspect 

给我留下了

package org.aspectj.lang.annotation does not exist 

我试图导入aspectj.jars(1.8.4版本)我在NetBeans库,没有任何影响。我只有弹簧框打开3.2.3释放xxxxxx的罐子。它仍然没有找到包。什么可能导致这个问题?这里是我的beans.xml的beggining

<?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" 
     xmlns:aop="http://www.springframework.org/schema/aop" 
     xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd 
     http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd 
     http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.2.xsd http://www.springframework.org/schema/context 
     http://www.springframework.org/schema/context/spring-context-3.2.xsd 
" xmlns:util="http://www.springframework.org/schema/util"> 

    <context:component-scan base-package="heyspring"> 

    </context:component-scan> 

    <aop:aspectj-autoproxy> 

回答

1

我建议你移动到Maven

即使你想不Maven的工作,仔细阅读以下注意事项。

注意:即使在Maven Central Repository你能下载罐子需要用下面分享我的依赖性根据

要完全确定你有你的pom.xml相当于罐子文件如下:

<dependency> 
    <groupId>org.springframework</groupId> 
    <artifactId>spring-aop</artifactId> 
    <version>${springframework.version}</version> 
</dependency> 

以下是强制性

<dependency> 
    <groupId>org.aspectj</groupId> 
    <artifactId>aspectjrt</artifactId> 
    <version>${aspectj.version}</version> 
</dependency> 
<dependency> 
    <groupId>org.aspectj</groupId> 
    <artifactId>aspectjweaver</artifactId> 
    <version>${aspectj.version}</version> 
</dependency> 

当然,您必须为Spring和AOP设置或配置每个版本。

我有这三个依赖关系,并在我的项目中正常工作。

相关问题