开发者

Spring 3 - Stop serializing an autowired bean

开发者 https://www.devze.com 2023-02-16 14:32 出处:网络
I have a session object which contains a reference to another object that I do not wish to 开发者_如何学Cserialize.

I have a session object which contains a reference to another object that I do not wish to 开发者_如何学Cserialize. Is it possible to do so using annotations?

@Component
 public class Model implements Serializable{
private static final long serialVersionUID = 1L;

    @Autowired
    private Validator validator;

Thanks in advance,


You can mark it with transient, though it would be null after deserialization.


You can also move the validation out of the POJO into a helper class. You could use the validation annotations from javax.validation describe in JSR-303. Here is a howto link: http://www.openscope.net/2010/02/08/spring-mvc-3-0-and-jsr-303-aka-javax-validation/

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号