Passing varargs to Spring spEL causes “Method cannot be found on com.sun.proxy”

前端 未结 1 1267
终归单人心
终归单人心 2021-01-23 10:01

I try to write custom class for permissions evaluation, so it can be used with Spring Security @PreAuthorize and Spring Expression Language like for example this (<

相关标签:
1条回答
  • 2021-01-23 10:39

    What version of Spring are you using? I just ran this test case with 4.3.12 and it worked fine...

    @SpringBootApplication
    public class So46953884Application {
    
        public static void main(String[] args) {
            SpringApplication.run(So46953884Application.class, args);
        }
    
        @Value("#{foo.foo('a', 'b')}")
        private String foo;
    
        @Bean
        public ApplicationRunner runner() {
            return args -> System.out.println(foo);
        }
    
        @Bean
        public Foo foo() {
            return new Foo();
        }
    
        public static class Foo {
    
            public String foo(String... strings) {
                return "filled: " + Arrays.toString(strings);
            }
    
        }
    
    }
    

    Result:

    filled: [a, b]
    
    0 讨论(0)
提交回复
热议问题