GStringImpl无法强制转换为java.lang.String [英] GStringImpl cannot be cast to java.lang.String

查看:572
本文介绍了GStringImpl无法强制转换为java.lang.String的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用Grails和Spring Security时出现以下错误.还有其他人有这样的问题吗?如果是这样,您的解决办法是什么?

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)

还有

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

推荐答案

您是否生成了所有类(用户,角色...). 您的命令看起来如何? 像这样的grails s2-quickstart com.testapp User Role? 检查您的配置,然后像本教程中那样尝试. Spring安全插件教程

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

实际上,此错误意味着在常规情况下,您使用诸如"$ {my_var}"之类的GString,并且某些类期望使用String.无法自动投射.如果您有类似这样的代码,则必须将其转换为这样的字符串:"${my_var}".toString().

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().

这篇关于GStringImpl无法强制转换为java.lang.String的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆