我使用maven程序集插件创建我的应用程序存档.我的pom中存在的所有依赖都包含在内,没有任何问题.
现在我需要包含两个或更多版本的相同工件.
如果在我的pom我放
<dependencies>
[...]
<dependency>
<groupId>db.test</groupId>
<artifactId>my-model</artifactId>
<version>1.0.3</version>
</dependency>
<dependency>
<groupId>db.test</groupId>
<artifactId>my-model</artifactId>
<version>1.1.0</version>
</dependency>
</dependencies>
Run Code Online (Sandbox Code Playgroud)
源代码依赖性解析器删除旧版本,只有1.1.0打包在存档中
我尝试使用程序集xml描述符文件包含jar.我没有找到任何解决方案.
一种可能的解决方案是手动将所有需要的model.jar放入文件夹中,并告诉程序集将其复制到存档中.但我正在寻找一个更可配置的解决方案.
任何的想法 ?
使用maven jar插件,我构建了两个jar:bar-1.0.0.jar和bar-1.0.0-client.jar.
实际上在我的POM中我有以下依赖:
<dependency>
<groupId>de.app.test</groupId>
<artifactId>foo</artifactId>
<version>1.0.0</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
此工件也存在于两个版本bar-1.0.0.jar和bar-1.0.0-client.jar中
我想使bar-1.0.0-client.jar依赖于foo-1.0.0-client.jar和bar-1.0.0.jar依赖于foo-1.0.0.jar.
================
- >第一个(错误的)解决方案:定义提供的范围,并在使用bar.jar时使用正确的foo包
- >第二个(长)解决方案:将"服务器"分类器添加到另一个jar中.使用不同的配置文件来构建foo工件并将分类器放在属性中.
<dependency>
<groupId>de.app.test</groupId>
<artifactId>foo</artifactId>
<version>1.0.0</version>
<classifier>${profile.classifier}<classifier>
</dependency>
Run Code Online (Sandbox Code Playgroud)
================
关于配置文件解决方案.
接口模块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/maven-v4_0_0.xsd">
<parent>
<groupId>com.app</groupId>
<artifactId>myapp-parent</artifactId>
<version>1.1.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.app</groupId>
<artifactId>myapp-interfaces</artifactId>
<version>1.1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>myapp Interfaces</name>
<profiles>
<profile>
<id>server</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<id>jar-server</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classifier>server</classifier>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>client</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution> …Run Code Online (Sandbox Code Playgroud) maven-2 classification dependency-management maven-plugin maven-jar-plugin
有人今天给我发了一个脚本,以#:开头,谷歌搜索后我没有找到任何答案.
即使脚本有效,我想知道这是什么意思.