1. <legend id='ylXBN'><style id='ylXBN'><dir id='ylXBN'><q id='ylXBN'></q></dir></style></legend><tfoot id='ylXBN'></tfoot>
        <bdo id='ylXBN'></bdo><ul id='ylXBN'></ul>
    2. <small id='ylXBN'></small><noframes id='ylXBN'>

      <i id='ylXBN'><tr id='ylXBN'><dt id='ylXBN'><q id='ylXBN'><span id='ylXBN'><b id='ylXBN'><form id='ylXBN'><ins id='ylXBN'></ins><ul id='ylXBN'></ul><sub id='ylXBN'></sub></form><legend id='ylXBN'></legend><bdo id='ylXBN'><pre id='ylXBN'><center id='ylXBN'></center></pre></bdo></b><th id='ylXBN'></th></span></q></dt></tr></i><div id='ylXBN'><tfoot id='ylXBN'></tfoot><dl id='ylXBN'><fieldset id='ylXBN'></fieldset></dl></div>

        将 Spring 依赖注入到 JPA 实体侦听器中

        Spring Dependency Injection into JPA entity listener(将 Spring 依赖注入到 JPA 实体侦听器中)

        <tfoot id='HRW1e'></tfoot>
          • <bdo id='HRW1e'></bdo><ul id='HRW1e'></ul>

                <tbody id='HRW1e'></tbody>

              <small id='HRW1e'></small><noframes id='HRW1e'>

            1. <legend id='HRW1e'><style id='HRW1e'><dir id='HRW1e'><q id='HRW1e'></q></dir></style></legend>
                1. <i id='HRW1e'><tr id='HRW1e'><dt id='HRW1e'><q id='HRW1e'><span id='HRW1e'><b id='HRW1e'><form id='HRW1e'><ins id='HRW1e'></ins><ul id='HRW1e'></ul><sub id='HRW1e'></sub></form><legend id='HRW1e'></legend><bdo id='HRW1e'><pre id='HRW1e'><center id='HRW1e'></center></pre></bdo></b><th id='HRW1e'></th></span></q></dt></tr></i><div id='HRW1e'><tfoot id='HRW1e'></tfoot><dl id='HRW1e'><fieldset id='HRW1e'></fieldset></dl></div>

                  本文介绍了将 Spring 依赖注入到 JPA 实体侦听器中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我需要将 Spring 依赖项注入到 JPA 实体侦听器中.我知道我可以使用 @Configurable 和 Spring 的 AspectJ weaver 作为 javaagent 来解决这个问题,但这似乎是一个 hacky 解决方案.还有其他方法可以完成我想做的事情吗?

                  I need to have a Spring dependency injected into a JPA entity listener. I know I can solve this using @Configurable and Spring's AspectJ weaver as javaagent, but this seems like a hacky solution. Is there any other way to accomplish what I'm trying to do?

                  推荐答案

                  另一个技巧是使用静态方法实现一个实用程序类,它可以帮助您在任何地方使用 Spring bean,而不仅仅是在托管类中:

                  Another trick is to implement an utility class with static method that helps you to use Spring beans everywhere, not only in managed classes:

                  @Component
                  public final class BeanUtil {
                  
                      private static ApplicationContext context;
                  
                      private BeanUtil(ApplicationContext context) {
                          BeanUtil.context = context;
                      }
                  
                      public static <T> T getBean(Class<T> clazz) throws BeansException {
                  
                          Assert.state(context != null, "Spring context in the BeanUtil is not been initialized yet!");
                          return context.getBean(clazz);
                      }
                  }
                  

                  这篇关于将 Spring 依赖注入到 JPA 实体侦听器中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How to send data to COM PORT using JAVA?(如何使用 JAVA 向 COM PORT 发送数据?)
                  How to make a report page direction to change to quot;rtlquot;?(如何使报表页面方向更改为“rtl?)
                  Use cyrillic .properties file in eclipse project(在 Eclipse 项目中使用西里尔文 .properties 文件)
                  Is there any way to detect an RTL language in Java?(有没有办法在 Java 中检测 RTL 语言?)
                  How to load resource bundle messages from DB in Java?(如何在 Java 中从 DB 加载资源包消息?)
                  How do I change the default locale settings in Java to make them consistent?(如何更改 Java 中的默认语言环境设置以使其保持一致?)
                  <i id='36LrM'><tr id='36LrM'><dt id='36LrM'><q id='36LrM'><span id='36LrM'><b id='36LrM'><form id='36LrM'><ins id='36LrM'></ins><ul id='36LrM'></ul><sub id='36LrM'></sub></form><legend id='36LrM'></legend><bdo id='36LrM'><pre id='36LrM'><center id='36LrM'></center></pre></bdo></b><th id='36LrM'></th></span></q></dt></tr></i><div id='36LrM'><tfoot id='36LrM'></tfoot><dl id='36LrM'><fieldset id='36LrM'></fieldset></dl></div>

                  • <legend id='36LrM'><style id='36LrM'><dir id='36LrM'><q id='36LrM'></q></dir></style></legend>
                      <tbody id='36LrM'></tbody>

                      • <tfoot id='36LrM'></tfoot>

                            <bdo id='36LrM'></bdo><ul id='36LrM'></ul>

                            <small id='36LrM'></small><noframes id='36LrM'>