2014-11-06 1 views
2

Spring 3.2에서 AspectJ를 사용하려고 Spring과 함께 여행을 떠난다. 다음 책 '스프링 액션 (Spring in Action)'에 이어. 어떤없이, 내가 넷빈즈에서 내 라이브러리에 aspectj.jars (버전 1.8.4)를 가져 오는 시도Spring이 AspectJ 패키지를 찾지 못한다

package org.aspectj.lang.annotation does not exist 

저 나뭇잎 그러나 그것을 사용

import org.aspectj.lang.annotation.Aspect 

: 저자는 AspectJ를 패키지이 방법을 가져 AspectJ를 사용 효과. 나는 스프링 프레임 3.2.3 릴리즈 xxxxxx의 12 개를 단지 울부 짖었다. 아직 패키지를 찾지 못했습니다. 무엇이이 문제를 일으킬 수 있습니까? 여기 당신이 메이븐없이 작업 할 경우에도

을 받는다는로 이동 제안

<?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

는주의 깊게 다음과 같은 메모를 읽어 내 beans.xml 환경의 beggining입니다.

: 당신이 항아리를 다운로드 할 수 있습니다 심지어 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> 

물론 스프링 및 AOP 용으로 각 버전을 설정하거나 구성해야합니다.

저는이 세 가지 종속성이 있으며 프로젝트에서 잘 작동합니다.

관련 문제