English 中文(简体)
以单独的maven 模块休息
原标题:rest as separate maven module

i m 设置一个新的多模块项目结构。 现在有一个ejb和一个耳朵模块, 我想为RESTful Web服务添加一个网络模块。 什么是最佳方法?

应用程序看起来是这样( 模块及其内容) :

  • app (pom): the parent pom
    • c或e (ejb): ejb, hibernate, DAOs, entities, business logic
    • ear (ear): the module that creates a deployable container

我现在要添加一个令人心烦的网络服务模块。

>http://www.jboss.或g/jbossas/downloads 查看jbos-as-7快速启动应用程序 总是有一个 模块,它只是为休息服务提供靴子,而配有 Jax-r 批注的豆子是ejb项目的一部分(我的情况是 col :

  • app
    • ejb (containing services + beans with jax-rs annotations)
    • ear
    • war (just containing a web.xml)

我使用这个方法的问题是, ejb 模块包含服务和其它资源。 保持它们分开是否更好? 还是这样走?

否则:哪一种办法会更好?

  • app
    • c或e
    • ear
    • rest (war which contains the rest resource beans and the web.xml)

  • app
    • c或e
    • ear
    • rest
    • rest-resources (separate container f或 the rest resource beans)
    • rest-war (war which only contains the web.xml)
最佳回答

从 JEE6/JAX-RS 的观点来看,你唯一需要的 WAR 文件就是实际有东西可以交给应用程序服务器来部署。 它实际上可以不包含任何资源( 除了将它变成一个有效档案所需要的资源除外), 只要您的课程在类路径上某处提供, 您的应用程序仍然有效 。 因此, 真正取决于您自己是否愿意将这些课程捆绑起来 。

您需要的是扩展 Javax.ws.rs.core. application 的类。 此类用作标记/ 启动装置, 向应用程序服务器显示网络归档中已有需要装入的 REST 资源。 在大多数商店里, 我见过这个类被放置在 WAR 项目本身 。

如果您真的在寻找组织方面的建议,我建议您首先将所有REST资源类别归并到自己的项目中。添加作为依附关系的项目,为资源类别工作所需的任何项目(例如您的核心和耳耳项目),加上所有三个(休息、耳、核心)作为战争项目的依赖性。

然后根据需要完善该模式,同时努力执行。

问题回答

有一种非常棒的JBoss Maven Arche类型 用于这种项目。

1) Go to eclipse with maven integration installed
2) New -> Project -> Maven Project
3) Click Next
4) In Filter type in ee6
5) Out of the options that appear, use Group ID: "org.jboss.spec.archetypes", and Artifact ID: "jboss-javaee6-webapp-archetype"
6) Out will come a beautifully structured web application project with EAR connecting to a EJB project and a WAR project.





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...