通知Spring AOP中的方法错误

计划我修订

我正在尝试在Spring AOP程序中运行建议,但我不断收到此错误:

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文件控制器之外,我已将Beans声明为批注:

样本Home.fxml文件控制器bean被注入,如下所示:

@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;
    }

}

Aspect类如下所示:

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

如何使建议方法运行,或者我错了?谢谢大家。

布拉格威

您的原型bean需要指定proxyMode,例如:

@Scope(proxyMode = ScopedProxyMode.TARGET_CLASS, value = "prototype")

巴里

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

Spring @事务中的方面(AOP)

来自分类Dev

如何使用Spring AOP记录方法链接

来自分类Dev

Spring AOP:使用后返回方法获取返回类型

来自分类Dev

Spring AOP:Xml vs AspectJ方法

来自分类Dev

关于在Qt中输入错误的弹出通知

来自分类Dev

带有groovy的Spring AOP:调用方法

来自分类Dev

控制器方法的Spring AOP传递参数

来自分类Dev

无法在Spring AOP中访问代理对象

来自分类Dev

使用spring aop在jar文件中剖析方法未发生

来自分类Dev

推送通知中的生产证书错误-PushSharp

来自分类Dev

Spring Boot中Aop的问题

来自分类Dev

欺诈活动通知HackerRank中的超时错误

来自分类Dev

如何摆脱通知功能中的同步错误?

来自分类Dev

Spring AOP-确定方法是否由@Scheduled调用

来自分类Dev

在模态中显示表单错误通知

来自分类Dev

如何使用Spring AOP记录方法链接

来自分类Dev

在Spring AOP中为方法编写的建议不会进入无限回调

来自分类Dev

在Spring AOP中获取会话

来自分类Dev

拆分方法时未应用Spring AOP

来自分类Dev

Spring AOP中的NamedParameterJdbcTemplate和CGlib

来自分类Dev

如何在每次调用Servlet中的服务方法之前使用Spring AOP运行代码

来自分类Dev

禁用Thunderbird错误通知中的声音

来自分类Dev

Spring AOP不是使用@Around注释的劫持方法

来自分类Dev

Mule / Spring-Java中的通知对象

来自分类Dev

使用Spring AOP拦截Jersey资源方法

来自分类Dev

未调用方法后的Spring Aop

来自分类Dev

由于响应中的错误结果,对 spring 方法的 Mockito 测试失败

来自分类Dev

在 Spring AOP 或 AspectJ 中拦截带注释的类和方法

来自分类Dev

Spring AOP - 在带注释的方法之间传递参数

Related 相关文章

热门标签

归档