329982 (1) [Avatar] Offline
#1
Hello,

After adding the Security components and the custom security config, I am getting the following error at compile time (using gradle build):

Task :compileJava
/Users/martinwunderlich/Dev/Spring/readinglist/src/main/java/com/myname/spring/readinglist/SecurityConfig.java:38: error: method findOne in interface QueryByExampleExecutor<T> cannot be applied to given types;
          UserDetails userDetails = readerRepository.findOne(username);
                                                    ^
  required: Example<S>
  found: String
  reason: cannot infer type-variable(s) S
    (argument mismatch; String cannot be converted to Example<S>)
  where S,T are type-variables:
    S extends Reader declared in method <S>findOne(Example<S>)
    T extends Object declared in interface QueryByExampleExecutor
1 error

> Task :compileJava FAILED

FAILURE: Build failed with an exception.


This compilation error is also picked up prior to compile time in my IDE (IntelliJ).
The problem seems to be caused by the type of the username parameter, which is of type String, but expected to be Example<S> where the type S should be UserDetails (I presume).
The other find methods on the repo object are working ok, but they return an object of type Optional<Reader>. So, I am able to do the following to get the code working:

UserDetails userDetails = readerRepository.findById(username).get();


The compilation error is confusing, because the Reader class does implement the UserDetails interface. But I am not familiar enough with the query-by-example mechanism to really understand what is happening here.
Can anyone help? Thanks a lot.

Kind regards,

Martin