Maven structure and Java EE applications

泪湿孤枕 提交于 2019-12-12 21:30:23

问题


How do you organize your Maven modules in a Java EE application? Currently what we do is have the following Maven modules under a parent POM:

  • ear
  • ejb
  • ejb-api
  • core

The ejb module contains only EJB classes, while the core module contains all other utility classes, including entities. The ejb-api is a lightweight module that contains local and remote interfaces, for inclusion in separate applications in needed. ear is used to make an EAR package and deploy it to application server.

How do you structure your application? I am particularly interested in where you store your utility classes and entity classes.


回答1:


Maven has the concept of archetypes that layout a pre-defined structure. I recommend the predefined archetypes from org.codehaus.mojo.archetypes. They have archetypes from desktop applications to server side applications (j2ee 1.3 to Java EE 6).




回答2:


IDE's like Websphere RAD, Oracle JDeveloper usually create different projects for each.

With maven, you can just use one module and extract common code, interfaces into the client jar using maven-ejb-plugin, ok keep them separate. Only thing is project should use one and follow a consistent approach

hth

<plugin>
  <artifactId>maven-ejb-plugin</artifactId>
  <configuration>
  <ejbVersion>3.0</ejbVersion>
  <generateClient>true</generateClient>
  <clientIncludes>
    <clientInclude>com/foo/goo/**/model/**</clientInclude>
   <clientInclude>com/foo/goo/**/service/**</clientInclude>
  </clientIncludes>
 </configuration>
</plugin>


来源:https://stackoverflow.com/questions/8849787/maven-structure-and-java-ee-applications

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!