Java – spring request scope bean

How do I set up a bean that will be created once upon request

I try to do this:

@Component
   @Scope(value = "request")
   public class TestBean {
        @postconstruct
        public void init() {
             System.out.println("start request");
        }

        @PreDestroy
        public void onDestroy() {
             System.out.println("ends request");
        }
   }

thank you.

Solution

Try this

For more details, please see this blog post

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>