I want create skeleton for big ecommerce project. It will be huge project. It should be a core module and set of additional modules.
Now I am thinking about maven modules into Spring MVC project. But I am newbie in maven and Spring
How make each module independent from other modules? Any best practice?
Any examples or code snippets?
I have a multi-module Maven project which was created couple of months back.
I can give you some pointers.
It can be structured as a parent project and multiple child modules under it.
In my case the output generated with Maven is a .war file and which contains jar files from each child module.
From maven you can build each modules separately if you want.
This is a useful link for multi-module creation
http://skillshared.blogspot.in/2012/11/how-to-create-multi-module-project-with.html
These are the layers on a high level:
Bean > Service > DAO [JPA]
Another useful link on directory structure is
Maven Multi Module Project Structuring Issues
Related
Let’s say in a multi-module project, each module is created by different teams, but each module is important for the project to work.
Each team should have its own module code, while other modules should appear in jar form.
Even when working through this git, they don’t have to see modifications in module codes that don’t belong to them.
But to test the project on the whole team, all the modules need to be used together.
I can do a multi-module project through maven, but when I put it on git, do I have to put each module in a separate repository?
how to they will find out what other module is in the new version in the version update of the modules?
You need to decide:
Will these modules always be built and tested together?
If yes: Put them into one git repository and use a multi-module structure. Everyone will checkout everything, but make changes only for their module.
If no: Separate the project in two or more multi-module projects in separate git repositories.
Hi I am converting a ear project to Maven. Below is the structure
-projA-ear
-projA-static
-projA-web
-shared-util
The shared util is shared by multiple unrelated projects handled by our team. Currently my deployment assembly is handled by eclipse and the shared-util.jar is automatically built inside the projA-web.war's WEB-INF/lib directory
When I convert my setup to Maven project, I am reading that I need multi module aggregator setup, and need to define shared-util as a module, and then define the aggregator POM as the parent to my modules. The problem is I cannot define projA-mvn as parent in the shared-util project as the other projects would be using it too as a module(when they decide to move to maven). Can someone please suggest a solution?
1) Make shared-util as a separate standalone Maven project.
2) Put projA-ear, projA-web and projA-static under a separate parent Maven project.
3) Declare shared-util jar as a dependency in your projA-web pom.
How can i combine two maven projects. One is webapp, and other is some javascript library (also webapp) which i want to combine with others project.
Or, would be better, how to add some outside folder with js files to maven project that can be deployed on testing server and then build to war.
Have a look at overlays in the Maven WAR Plugin documentation. This explains how Maven merges resources from different web projects into a single WAR.
In a nutshell, you create several WAR files of all the dependencies (usually, you already have this but you can even do this if they aren't real working web projects). Then you can pull these in as dependencies. The important part here is to specify the type of the dependency (<type>war</type>); otherwise Maven will try to add the JAR.
The WAR plugin will notice the additional WARs in the list of dependencies and merge them.
You can create One parent project and Two modul project. You will have 3 pom.xml files.
modul projects extendens dependencies from parent project. Maven parent pom vs modules pom, Multimodule project
Maven WAR Overlays could solve the problem. If you have two maven web projects, and one of your Web Project depends on the other's you could declare the dependent project as a dependency and do an overlay.
Reference:
http://maven.apache.org/plugins/maven-war-plugin/overlays.html
I have a Maven web project (Java) that I created in Eclipse. Due to in house IDE restriction I had to move the project to JDeveloper 12c and disable the Maven nature. I had to make several tweaks to project's properties in JDeveloper to make it work.
We found that the back-end code (Service Impl, DAO and Entity classes) can be used on several other projects so we are evaluating/considering to separate the single large web project into 2 projects. One for the front end, which is specific for each project and the other for backend, which is common for all projects.
Here are few ways I thought it can done.
1) From the single large web project, create 2 projects; web UI project and web back-end project.
2) Keep the code as it is and use maven modules or maven overlays feature and generate 2 wars from the same code.
I have not dealt with the projects depending on others or multi module projects a lot. Do you see any issues with this type of architecture, good or bad!
Please let me know if you have any other suggestions or ran into similar situations before. Thanks in advance.
Splitting project into many subproject is a good idea. You could use maven multimodule project setup (docs). Every frontend project would have a separate maven project (module in parent pom) and you'll have one project (module) for the backend.
Depending on your requirements you could then create:
an EAR archive with backend in EJB jar and all frontends in WAR archives,
a WAR archive for every frontend project with EJB jar (or jar for non-plain-javaee setup) inside WEB-INF/lib.
Multimodule setup has few advantages and the main one is that you can build the whole application from scratch just by issuing single mvn command.
I have two questions about maven project structure:
1) I am creating a maven multi-module project and would like to know if I can put all the common dependencies of the modules in the parent pom? Is that the right way to do?
2) If I am creating a maven webapp project that contains all web.xml and JSP files, where should the web controllers, listeners and model objects be residing? In a separate maven jar project or in the same webapp project?
1) Read up on the difference between dependencyManagement and dependencies. Putting all common dependencies in the parent POM will work, but it's likely to cause spurious dependencies when you add a new module.
dependencyManagement is recommended. You can specify all versions and exclusions in a central place, and then it's enough to specify groupId and artifactId for each dependency of each module.
2) Java sources directly related to the web layer usually go into the war module (unless you want to reuse them for a different project, then it's better to factor them out into a separate jar).