我在.NET世界中经历了很长一段时间后才回到Java / Eclipse世界。我对Maven也有点新意并掌握它,但是有点困境...
我目前正在开发一些Spring-Boot服务。这两个都取决于我开发的新库,我计划在其他项目中重复使用。
为方便起见,我开始在一个空的基于POM的父项下设置3个eclipse项目作为模块:
父POM
LibB依赖于LibA,Service1依赖于LibA和LibB。
但是,后来需要Service2,这将取决于LibA。
所以,我决定摆脱父POM并制作Service1,LibA,LibB和现在的Service2独立的eclipse / maven项目。我认为这也允许我在Git中独立管理它们。
我尝试定义项目内存储库,我可以在Servcie1,Servcie2和LibB中包含LibA和LibB jar(因为LibB依赖于LibA)。然而,eclipse / maven似乎没有接受这个...而不是拿起罐子,它似乎直接引用了lib项目(见截图)。
这里最好的方法是什么?
cx-config-service POM:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.2.RELEASE</version>
<relativePath />
</parent>
<groupId>com.esi.cx</groupId>
<artifactId>cx-config-service</artifactId>
<version>1.0.0-SNAPSHOT</version>
<properties>
<java.version>1.7</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<!-- Leaving out irrelevant dependencies for brevity ... -->
<dependency>
<groupId>com.esi.cx</groupId>
<artifactId>cx-utility</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.esi.cx</groupId>
<artifactId>cx-genesys</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
cx-genesys POM:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.esi.cx</groupId>
<artifactId>cx-genesys</artifactId>
<version>1.0.0-SNAPSHOT</version>
<properties>
<java.version>1.7</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>repo</id>
<name>repo</name>
<releases>
<enabled>true</enabled>
<checksumPolicy>ignore</checksumPolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<url>file://${project.basedir}/repo</url>
</repository>
</repositories>
<dependencies>
<!-- Leaving out irrelevant dependencies for brevity ... -->
<dependency>
<groupId>com.esi.cx</groupId>
<artifactId>cx-utility</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
cx-utility POM:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.esi.cx</groupId>
<artifactId>cx-utility</artifactId>
<version>1.0.0-SNAPSHOT</version>
<properties>
<java.version>1.7</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<!-- Leaving out irrelevant dependencies for brevity ... -->
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>