0
我试图运行在Spring AOP程序的提醒,但我不断收到此错误:Advise方法错误
Exception in Application start method
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:367)
at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:305)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Caused by: java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:894)
at com.sun.javafx.application.LauncherImpl.access$000(LauncherImpl.java:56)
at com.sun.javafx.application.LauncherImpl$1.run(LauncherImpl.java:158)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: .......
Caused by: java.lang.IllegalArgumentException: Can not set .......
我的问题是,我有原型豆,我认为(但我不确定)可能是在这个错误后面。
我已经声明为注解我的豆子,除了它们经由AppFactory类注射FXML文件控制器:
样本Home.fxml
文件控制器豆被注入像这样:
@Configuration
public class AppFactory {
@Bean
public HomeController homeController() throws IOException {
return (HomeController) loadController("/Home.fxml");
}
FXMLLoader loader = null;
protected Object loadController(String url) throws IOException {
loader = new FXMLLoader(getClass().getResource(url));
loader.load();
return loader.getController();
}
}
的那些
@Component
@Scope("prototype")
@Entity
@Table(name = "ENTITY_OBJECT")
public class EntityObject extends RevEntity {
private String name;
public String getName() {
return name;
}
}
方面类的样子:
01通过注释一类的样子,例如申报@Aspect
public class SampleAopAspect {
@Before("execution(public String getName())")
public void timeUpdataedAdvice() {
System.out.println("Before method ->");
}
}
的FXML文件看起来像:
<?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.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd ">
<aop:aspectj-autoproxy />
<bean id="sampleAopAspect" class="org.SampleAopAspect" />
<context:annotation-config/>
<context:component-scan base-package="wakiliproject"/>
</beans>
我怎样才能使建议的方法来运行,或whare我要去错了吗?谢谢大家。
感谢您的答复@blagerweij。现在我得到错误'切入点不正确:在字符位置期待')'! – 2014-11-24 00:30:23
你在上面的问题中的切入点语法是正确的,所以你必须改变一些东西。如果您希望我们帮助您发现语法错误,那么与我们分享代码如何? – kriegaex 2014-11-24 10:57:39
您在SampleAopAspect中使用内联切入点,应该没问题。你确定提供的代码片段被正确复制?例如,'EntityObject'类同时是'Component'和'Entity',这是非常不寻常的。 顺便说一句,如果你正在寻找一种方法来填充上次修改的用户名和时间戳,你可能想看看spring-data AuditorAware: ' ' 请参阅[http://projects.spring.io/spring-data-jpa/] –
blagerweij
2014-11-24 22:39:15