2014-11-06 103 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設置或配置每個版本。

我有這三個依賴關係,並在我的項目中正常工作。

相關問題