Springboot的AOP不生效

最新写的webservice用aop写日期和数据库,但是一直不生效.最后查明

在webservice注册时,在实例化Endpoint时,是用的new方法实例话ws,而不是用spring托管的ws


问题代码:

    @Bean
    public Endpoint endpointCreateContract() {
        EndpointImpl endpoint = new EndpointImpl(springBus(), new CreateContractWS());
        endpoint.publish("/createContract");
        return endpoint;
    }

修复后代码

    @Bean
    public CreateContractWS createContract() {
        return new CreateContractWS();
    }
    @Bean
    public Endpoint endpointCreateContract() {
        EndpointImpl endpoint = new EndpointImpl(springBus(), createContract());
        endpoint.publish("/createContract");
        return endpoint;
    }


你可能感兴趣的:(Java)