gpt4 book ai didi

maven-2 - 是否有用于在 J2EE 应用程序中打包实体 bean 的 Maven 插件?

转载 作者:行者123 更新时间:2023-12-04 06:47:45 25 4
gpt4 key购买 nike

我还没有找到可以打包我的应用程序并将其部署到 Glassfish 且不会出错的 Maven 插件或目标。我得到这个异常(exception):

[ERROR] com.sun.enterprise.admin.cli.CommandException: remote failure: Exception while preparing the app : java.lang.RuntimeException: Could not resolve a persistence unit corresponding to the persistence-unit-ref-name [org.us.impl.MyClass/entityManagerFactory] in scope of the module called [man-java-really-stinks-app]. Please verify your application.



这不是 Spring/Hibernate/EntityManagerFactory/Jpa 问题。该应用程序在嵌入式 Maven Glassfish 容器中运行良好。

我在 pom.xml 中将包装更改为 ear 并在部署到 Glassfish 时得到了这个

Error during deployment : org.xml.sax.SAXParseException: The content of element type "application" is incomplete, it must match "(icon?,display-name,description?,module+,security-role*)".



是否有一个插件可以处理 J2EE 打包要求?

额外的问题:由于实体(只是 POJOS!)和应用程序需要以不同的方式打包,最好将它们分成 Maven 子项目吗?

最佳答案

I haven't found a Maven plugin or target that will package my app and deploy it to Glassfish without error.



对于包装,有您需要的一切: maven-jar-plugin对于 JAR(包括打包 JPA 实体的 JAR), maven-war-plugin对于 WAR, maven-ejb-plugin对于 EJB-JAR, maven-ear-plugin对于 EAR, maven-rar-plugin用于资源适配器。

This isn't a Spring/Hibernate/EntityManagerFactory/Jpa problem. The app runs fine in the embedded Maven Glassfish container.



好吧,我仍然很想说无论如何都存在 JPA 配置问题,容器显然无法找到(默认?)持久性单元。但是由于我不知道您正在运行哪种应用程序(我猜它是一个网络应用程序,但希望得到确认),您的 persistence.xml看起来,你如何注入(inject) EntityManager ,您如何配置数据库访问,您如何配置 Spring,您正在运行的 GlassFish 版本等等,很难说更多。

I changed packaging to ear in my pom.xml and got this when I deployed to Glassfish



那不是那么容易。构建 EAR 通常涉及多模块构建,并且您需要提供特殊的部署描述符。但我不相信您需要 EAR 包装,如果可以避免,请不要使用它。

IS there a plugin that will take care of the J2EE packaging requirements?



正如我所说,从 J2EE 到 Java EE 6,您需要的一切都有插件。只需提供上面要求的详细信息。

Bonus question: Since the Entities (just POJOS!) and the application need to be packaged differently, is it best to separate these into Maven sub-projects?



实体和应用程序不需要(总是)以不同的方式打包,您可以直接在 WAR 中打包实体(我在推断,但我怀疑这是您的情况)。我只是认为您在某个地方存在配置问题,即使应用程序在 GF Embedded 中运行。

顺便说一句,Java EE 中几乎所有东西都是 POJO(实体、 session Bean、消息驱动 Bean 等),但对打包没有直接影响,打包和 POJO 无关。

关于maven-2 - 是否有用于在 J2EE 应用程序中打包实体 bean 的 Maven 插件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3531044/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com