Springspectj jar 未正确配置

发布于 2024-10-11 16:03:35 字数 279 浏览 9 评论 0原文

当我尝试使用 Roo 创建的 JPA 对象时,出现此错误。

尚未注入实体管理器(Spring Aspects JAR 是否配置为 AJC/AJDT 方面库?)

我已经按照一些在线建议将 spring-aspects.jar 添加到 Eclipse 中的aspectj路径,但我仍然收到此错误。有谁知道如何解决这个问题?

我使用的环境是Spring 3.0.5、Hibernate 3.6和JBoss 6.0.0.Final。

I am getting this error when I tried to use a JPA object created by Roo.

Entity manager has not been injected (is the Spring Aspects JAR configured as an
AJC/AJDT aspects library?)

I have followed some online advice to add the spring-aspects.jar to aspectj path in Eclipse but I still get this error. Does anyone know how to solve this?

The environment I am using is Spring 3.0.5, Hibernate 3.6 and JBoss 6.0.0.Final.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

不乱于心 2024-10-18 16:03:35

转到 STS ROO 控制台(在 STS 中的项目中右键单击,然后单击 Spring Tools,然后单击 Open Spring Roo)
在提示符下输入perform clean(将执行Maven clean)
然后输入执行 eclipse

它应该可以工作!

Go to STS ROO console (right click in the project in STS, then Spring Tools, then Open Spring Roo)
Type in the prompt perform clean (will perform Maven clean)
Then type perform eclipse

It should work!

倾城花音 2024-10-18 16:03:35

看来您还没有注入实体管理器。

Webapps(可能的原因):

  • 您没有将实体管理器工厂添加到 applicationContext.xml

Java 应用程序

  • 您没有将实体管理器工厂添加到 applicationContext.xml
  • < p>应用程序初始化错误(见下文)

    公共类 SampleApp {
        公共静态无效主(字符串[] args){
            SampleApp obj = new SampleApp();
    
            // 将依赖注入到应用程序中
            可配置应用程序上下文 applicationContext = 
                    new ClassPathXmlApplicationContext("/applicationContext.xml");
            applicationContext.registerShutdownHook();
            applicationContext.getBeanFactory().autowireBeanProperties(
                    obj, AutowireCapableBeanFactory.AUTOWIRE_NO, false);
    
            // 做工作
        }
    }
    

Looks like you haven't injected Entity Manager.

Webapps (possible causes):

  • You didn't add entity manager factory to your applicationContext.xml

Java Applications:

  • You didn't add entity manager factory to your applicationContext.xml
  • Wrong application initialization (see below)

    public class SampleApp {
        public static void main(String[] args) {
            SampleApp obj = new SampleApp();
    
            // Injecting dependencies into application
            ConfigurableApplicationContext applicationContext = 
                    new ClassPathXmlApplicationContext("<PATH-TO>/applicationContext.xml");
            applicationContext.registerShutdownHook();
            applicationContext.getBeanFactory().autowireBeanProperties(
                    obj, AutowireCapableBeanFactory.AUTOWIRE_NO, false);
    
            // Do the work
        }
    }
    
波浪屿的海角声 2024-10-18 16:03:35

我也遇到了这个问题,并在这里找到了答案: http://whyjava.wordpress.com/2012/02/13/fixing-exception-entity- manager-has-not-been-injected-is-the-spring-aspects-jar-configured-as-an-ajcajdt-aspects-library/

在我的例子中,我需要创建一个名为 的文件_Roo_Configurable.aj 包含以下内容:

特权方面_Roo_Configurable { 声明 @type:: @Configurable;这

解释了为什么现有的类可以工作,但我创建的新类却不能。 _Configurable.aj 文件没有(并且仍然没有)显示在 STS 的包资源管理器中。

(我知道这个答案太晚了,但我希望它对其他人有帮助!)

I had this problem too, and found the answer here: http://whyjava.wordpress.com/2012/02/13/fixing-exception-entity-manager-has-not-been-injected-is-the-spring-aspects-jar-configured-as-an-ajcajdt-aspects-library/

In my case, I needed to create a file called <classname>_Roo_Configurable.aj with the following content:

privileged aspect <classname>_Roo_Configurable { declare @type: <classname>: @Configurable; }

This explained why existing classes worked but new ones that I had created did not. The _Configurable.aj file did not (and still does not) show up in the package explorer in STS.

(I know this answer is incredibly late but I hope it helps someone else!)

云醉月微眠 2024-10-18 16:03:35

我遇到了同样的问题,并通过执行 Spring Tools | 解决了它在我的项目上启用 Spring Aspects 工具。

我的类是由 Roo 生成并推入的(我遇到了太多问题),我只是将它们添加到我创建的全新 Google Web 应用程序项目中(因此它使用带有 war 目录的 GAE 应用程序布局,并且没有Maven 适合任何东西,至少现在还不是)。

I was having this same issue and fixed it by doing Spring Tools | Enable Spring Aspects Tooling on my project.

My classes were generated by Roo and pushed in (I was having way too many issues with it), and I simply added them to a brand new Google Web Application Project I created (so it uses GAE's app layout with a war directory, and no Maven for anything, at least not yet).

_蜘蛛 2024-10-18 16:03:35

您必须为指示域创建存储库。

在 roo-terminal 中运行以下脚本

es。

 repository jpa --interface ~.dao.MyDomainDAO --entity ~.domain.MyDomain

You have to create the repository for the indicate domain.

In roo-terminal run the follow script

es.

 repository jpa --interface ~.dao.MyDomainDAO --entity ~.domain.MyDomain
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文