Frage

I have 3 Java projects with the same entities.

I want to share entities between these projects because entities can evolve during the development phase.

We are thinking about building a jar with entities and sharing it using Maven (with a repository).

Maybe you have another solution ?

War es hilfreich?

Lösung

I also can recommend to use Maven to share code between projects.

Here are some tips to get started:

  • Use a Maven Repository Manager such as Nexus. It will help you to create a stable development environment.
  • Every developer (also the Continuous Integration Server user) should configure their settings file to use your Maven Repository Manager. Don't specify your repositories in the POMs, confiugre them only in your Maven Repository Manager. http://www.sonatype.com/books/nexus-book/reference/maven-sect-single-group.html
  • Use the dependencyManagement and pluginManagement elements of your parent POMs to specify all versions of the plugins and dependencies you are using. Omit these versions in the other POMs (they will inherit them from the parent POM).
  • I also recommend to use different POMs for multi-module builds and parent POMs.

Andere Tipps

If you want to share common interfaces, classes, functionality or components, Maven is the way to go. In addition to the dependency management, you also get the added bonus of a standard project layout that will simplify things. Easy integration with most common continuous integration servers and a standard release process are further benefits.

Definitely take a look at Maven!

making an own JAR-library is definitely a good solution.

  • The jar-file is easy to distribute via dependency management (maven, ivy, gradle ..)
  • The jar is versioned
  • The projects using the library can be tested against a certain verion. Otherwise it may gets a problem if you change enties and forget to change a depending project. -> integration tests

Regards

Entities are the representation of a given object am I correct? If so the default mechanism implemented by Java is Object serialization - http://en.wikipedia.org/wiki/Serialization. In the case of jar files if an entity changes you would have to change jar once again each time as well. It may be tedious.

Geneate a standard war file in roo.. But then change it's package to jar file.

Then from any standard war file you can just deploy this jar (Ill use the jar as a maven dependency). Ill maintain a unique named applicationConext like pizzaShop-applicationContext.xml and like pizzaShop-applicationContext-jpa.xml. so from a parent spring project I can stack up various roo projects in this fashion.

Ill also keep their generated webapps folder to allow for the generator to work more easily. (This means I have to open up the pom.xml and keep changing it back to jar). Also helps with cut and paste fodder for non roo generated war files web.xml entry additions.

Seems like it may be a confusing point about roo.. You can just mix and match these jars as you would any spring project. They function like self contained units of springness and work fine sitting side by side with other spring jars all under the same webapp/web.xml context.

Its tedious but still better then writing spring code by hand.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top