如果通过Spring包装到代理中,如何知道原始类名? [英] How to know original class name if wrapped into proxy by Spring?

查看:631
本文介绍了如果通过Spring包装到代理中,如何知道原始类名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过Spring下的getClass().getSimpleName()获取一些类名称,并且它返回类似

I am trying to obtain some classes name by getClass().getSimpleName() under Spring and it returns something like

MyClass$$EnhancerBySpringCGLIB$$SOMEHEX

这可能是因为Spring将类包装到代理中.

This is probably because Spring wraps the class into proxy.

是否有任何可移植的方法来获取原始的类名?

Is there any portable way to obtain original class name?

推荐答案

Spring为此提供了实用程序.

Spring provides a utility for this.

返回给定类的用户定义类:通常只是给定类,但如果是CGLIB生成的子类,则返回原始类."

"Return the user-defined class for the given class: usually simply the given class, but the original class in case of a CGLIB-generated subclass."

这篇关于如果通过Spring包装到代理中,如何知道原始类名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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