Can not set field to com.sun.proxy.$Proxy
Can not set 'FileValidator' field 'FileController.validator' to 'com.sun.proxy.$Proxy101'
FileValidator
is a class, not an interface.
com.sun.proxy.$Proxy101
is an interface proxy, not a class proxy.
There are two main ways to solve this. Either inject the validator via an interface, e.g:
@Autowired @Qualifier("fileValidator")
private Validator fileValidator;
or enable class-proxies, e.g:
@SpringBootApplication
@EnableAspectJAutoProxy(proxyTargetClass = true)
public class Application {
Those are just examples, there will be other ways to implement those two solutions.
Autowire the interface of FileValidator(class)
in your class FileController
.
Doing this will not require you to specify @Qualifier as mentioned below:
@Autowired
IFileValidator filevalidator;