GStringImpl cannot be cast to java.lang.String

那年仲夏 提交于 2020-02-27 15:06:28

问题


I got the error below using Grails and Spring Security. Has anyone else had a problem like this? If so, what was your fix?

Error |
Exception in thread "Thread-15" 
Error |
java.lang.ClassCastException: org.codehaus.groovy.runtime.GStringImpl cannot be cast to java.lang.String
Error |
    at org.codehaus.groovy.grails.project.compiler.GrailsProjectWatcher.run(GrailsProjectWatcher.java:114)

And

java.lang.IllegalArgumentException: Failed to evaluate expression 'User_name'

回答1:


Did you generate all the classes (User, Role ...). How does your command looks like? Like this grails s2-quickstart com.testapp User Role? Check your configuration and try it like in this tutorial. Spring Security Plugin Tutorials

Actually this error means in groovy that you use a GString like "${my_var}" and some class expects String. It can't be cast automatically. If you have some code like this, you have to convert it to String like this: "${my_var}".toString().



来源:https://stackoverflow.com/questions/29079574/gstringimpl-cannot-be-cast-to-java-lang-string

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!