I am writing implicit writes for a few Java DO Classes so I can use Json.toJson() to return the data as a JSON String.
I created an object ImplicitsWrites where I have them and imported it into my controller class.
However, during complilation I get:
value getUserId is not a member of com.domain.UserDO
Note: implicit value <myDOClass> is not applicable here because it comes after the application point and it lacks an explicit result type
Just a note, getUserId() is valid method in the DO.
An example write is this:
implicit val userDOWrite = new Writes[UserDO] {
def writes(userDO: UserDO) = Json.obj(
"userId" -> userDO.getUserId(),
"rowType" -> userDO.getName()
)
}
Just a note. Maybe this will help identify the problem. The DO has @Data annotation (lombok) so the get/set methods are generated.
Am I defining the implicit wrong? If so, what is the proper way of doing it?
extends AnyRefhas nothing to do there. The main issue isvalue getUserId is not a member of com.domain.UserDO. Check in the scala consoleimport com.domain.UserDO; new UserDO(..).getUserId- cchantepconsolefrom SBT) - cchantep