亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'aspectJ' defined in class path resource [ApplicationContext.xml]: BeanPostProcessor before instantiation of bean failed; nested exception is

錯誤信息:

Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'aspectJ' defined in class path resource [ApplicationContext.xml]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.aop.aspectj.AspectJPointcutAdvisor#0': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.aop.aspectj.AspectJPointcutAdvisor]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: Pointcut is not well-formed: expecting ')' at character position 30

extucion(*com.demo.service.*.*(..))

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ^


ApplicationContext.xml

<?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.0.xsd

? ? ? ? ? ?http://www.springframework.org/schema/context

? ? ? ? ? ?http://www.springframework.org/schema/context/spring-context-3.0.xsd

? ? ? ? ? ?http://www.springframework.org/schema/aop

? ? ? ? ? ?http://www.springframework.org/schema/aop/spring-aop-3.0.xsd

? ? ? ? ? ?">


<bean id="aspectJ" class="com.demo.aspect.AspectJ"></bean>

<bean id="aspectService" class="com.demo.service.AspectService"></bean>

<!-- 切面的配置 -->

<aop:config>

<aop:aspect id="aspectJAOP" ref="aspectJ">

<!-- 切入點的配置 -->

<aop:pointcut expression="extucion(*com.demo.service.*.*(..))" id="aspectPointcut"/>

<!-- beforeAdvice的聲明 -->

<aop:before method="before" pointcut-ref="aspectPointcut"/>

</aop:aspect>

</aop:config>


</beans>


AspectJ.java

package com.demo.aspect;


import org.aspectj.lang.annotation.Aspect;



@Aspect

public class AspectJ {

public void before(){

System.out.println("Before");

}

}

AspectService.java

package com.demo.service;


public class AspectService {

public void service(){

System.out.println("AspectService service");

}


}

SpringText.java

package com.demo.test;


import org.springframework.context.ApplicationContext;

import org.springframework.context.support.ClassPathXmlApplicationContext;


import com.demo.aspect.AspectJ;

import com.demo.service.AspectService;


public class SpringTest {


public static void main(String[] args){

ApplicationContext ctx=new ClassPathXmlApplicationContext("ApplicationContext.xml");

AspectService service= (AspectService) ctx.getBean("aspectService");

service.service();

}

}


正在回答

1 回答

你的SpringTest是JUnit單元測試嗎 單元測試要寫@Test注解然后右鍵這個方法名 run as JUnit?而且不是在main方法那里運行吧,具體你可以參考老師單元測試的寫法

0 回復 有任何疑惑可以回復我~
#1

qq_慕斯8337134 提問者

非常感謝!
2016-11-15 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'aspectJ' defined in class path resource [ApplicationContext.xml]: BeanPostProcessor before instantiation of bean failed; nested exception is

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號