问题
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