简体   繁体   中英

Multi-project app in Eclipse with maven

I'm used to Visual Studio, so Eclipse is very new for me.

I have to start (ASAP) developing a project that contains 3 subprojects:

1 - Business logic library with Hibernate support 2 - JavaFX configuration utility 3 - Spring MVC app with a lot of JavaScript inside

2 and 3 use 1 as a core.

I've tried to google manual but all of them were about parts of this task, nothing about the complete solution.

I can create all 3 projects and put them in same subdirs in a solution directory. But how to connect them to core lib? Maven looks great for it, but I can't explain him how modules have to be connected.

How to make such a structure?

Google for "maven dependency plugin" or "maven dependency management".

In pom.xml (which is maven's configuration file) use 'dependency'. Say if your modules are named

  • com.acme:business
  • com.acme:javafx
  • com.acme:spring

Then, if you add the following into .javafx & .spring maven will know that your modules do depend on 'business':

<project>
  ...
  <dependencies>
    <dependency>
      <groupId>com.acme</groupId>
      <artifactId>business</artifactId>
      <version>1.0</version>
    </dependency>
  </dependencies>
</project>

Also, it is important you learn how eclipse works with maven, try googling that. Also this SO question might be helpful to start using mven in eclipse: Maven in Eclipse: step by step installation

At the risk of being shot down in flames, in my opinion Eclipse does not handle structured projects as well as Visual Studio. (I program Java/Eclipse at work and use VS aka Atmel Studio at home for hobbyist C++/Arduino projects).

In Eclipse, I have found to best to check out each component to the top level and compile each component separately (mvn clean install). The output of this is generally a .jar file that will be installed in your local maven repository. You then list that jar as a dependency in the pom.xml file of the higher-level components.

I suggest you install M2Eclipse or some other Maven client into Eclipse. They are not perfect, but are far more productive than doing everything manually.in my opinion.

Also Eclipse supports multiple workspaces quite well. One workspace per major multi-component project works well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM