我正在写第一个AOP代码。我已经使用 maven 3.3 添加了代码和相关的依赖项,但是当我尝试运行我的代码时我得到了以下异常,尽管它编译得很好。
我怀疑这与我在pom中使用 java 7添加的依赖项的版本/兼容性有关。
例外:
<dependency>
<groupId>asm</groupId>
<artifactId>asm</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<version>1.7.0</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.7.0</version>
</dependency>
的pom.xml:
<aop:aspectj-autoproxy></aop:aspectj-autoproxy>
<bean id="models" class="com.myproject.models.Users"><property name="name" value="Dummy Name"></property></bean>
<bean id="userservice" class="com.myproject.userService"><property name="users" ref="models"></property></bean>
<bean name="userAroundadvice" class="com.myproject.models.Aopclass" />
App-Context xml:
<rich:column id="date" sortBy="#{rs.changeDate}" sortOrder="descending">
<f:facet name="header">
<h:commandLink value="#{msg.entryDate}" styleClass="tableColumnHeader">
<rich:componentControl target="noteTable" operation="sort">
<f:param name="column" value="date" />
<f:param value="" />
<f:param name="reset" value="true" />
</rich:componentControl>
<h:graphicImage value="/images/sort/sort_asc.gif"
style="border: 0px; vertical-align: middle;"
rendered="#{chNotesAction.list.order == 'changeDate ASC'}" />
<h:graphicImage value="/images/sort/sort_des.gif"
style="border: 0px; vertical-align: middle;"
rendered="#{chNotesAction.list.order == 'changeDate DESC'}" />
<h:graphicImage value="/images/sort/sort_uns.gif"
style="border: 0px; vertical-align: middle;"
rendered="#{chNotesAction.list.order != 'changeDate ASC'
and chNotesAction.list.order != 'changeDate DESC'}" />
</h:commandLink>
</f:facet>
<h:outputText value="#{rs.changeDate}">
<f:convertDateTime timeZone="#{referenceData.timezone}" pattern="MMM dd, yyyy HH:mm" />
</h:outputText>
</rich:column>
答案 0 :(得分:0)
每个根本原因java.lang.NoClassDefFoundError: org/aspectj/weaver/BCException
,
aspectjweaver.jar
不在您的类路径中,请在pom
中添加以下依赖项:
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.6.1</version>
</dependency>