我在eclipse中有一个名为abc的spring项目。我需要创建一个项目的罐子。这个项目依赖于abc-lt-核心。我无法控制这种依赖
<dependency>
<groupId>com.abc.lt</groupId>
<artifactId>abc-lt-core</artifactId>
<version>5.1.4</version>
</dependency>abc-主叫者
<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.abc</groupId>
<artifactId>abc-caller</artifactId>
<version>1.0</version>
<name>caller</name>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>*.*</exclude>
</excludes>
<filtering>false</filtering>
</resource>
</resources>
<defaultGoal>install</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<finalName>Caller</finalName>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<Main-Class>com.abc.Caller</Main-Class>
<Build-Number>1</Build-Number>
</manifestEntries>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-all</artifactId>
<version>5.8.0</version>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-pool</artifactId>
<version>5.8.0</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jms</artifactId>
<version>3.2.4.RELEASE</version>
</dependency>
<dependency>
<groupId>com.abc.lt</groupId>
<artifactId>abc-lt-core</artifactId>
<version>5.1.4</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>3.2.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jmx</artifactId>
<version>2.0.8</version>
</dependency>
</dependencies>
</project>在构建maven项目时,我得到以下错误
Downloading: http://repo.maven.apache.org/maven2/com/abc/lt/abc-lt/${masterVersionNumber}/abc-lt-${masterVersionNumber}.pom
Downloading: http://repo.opengeo.org/com/abc/lt/abc-lt/${masterVersionNumber}/abc-lt-${masterVersionNumber}.pom
Downloading: http://www.hibernatespatial.org/repository/com/abc/lt/abc-lt/${masterVersionNumber}/abc-lt-${masterVersionNumber}.pom
Downloading: http://repo1.maven.org/maven2/com/abc/lt/abc-lt/${masterVersionNumber}/abc-lt-${masterVersionNumber}.pom
---------
BUILD FAILURE
-----------------
Failed to execute goal on project abc-lt-caller: Could not resolve dependencies for project com.abc:abc-lt-caller:jar:1.0:
Failed to collect dependencies for [org.apache.activemq:activemq-all:jar:5.8.0 (compile),
org.apache.activemq:activemq-pool:jar:5.8.0 (compile), org.springframework:spring-jms:jar:3.2.4.RELEASE (compile),
com.abc.lt:abc-lt-core:jar:5.1.4 (compile), org.springframework:spring-core:jar:3.2.4.RELEASE (compile),
org.springframework:spring-jmx:jar:2.0.8 (compile)]:
Failed to read artifact descriptor for com.abc.lt:abc-lt-core:jar:5.1.4:
Could not transfer artifact com.abc.lt:abc-lt:pom:${masterVersionNumber}
from/to central (http://repo.maven.apache.org/maven2): Illegal character in path at index 71:
http://repo.maven.apache.org/maven2/com/abc/lt/abc-lt/
${masterVersionNumber}/abc-lt-${masterVersionNumber}.pom -> [Help 1]发布于 2014-11-07 22:24:20
您的问题不在于您的项目,而在于依赖项目的POM。
您所得到的错误是告诉您,URL/路径上有一个非法字符,它阻止Maven解决依赖关系。
未能读取com.abc.lt:abc-lt-core:jar:5.1.4:未能将工件com.abc.lt:abc:pom:${masterVersionNumber}从/转到中心(http://repo.maven.apache.org/maven2):索引71: http://repo.maven.apache.org/maven2/com/abc/lt/abc-lt/ -> Help 1路径中的非法字符
请看粗体文字。它没有解析${masterVersionNumber}属性。我怀疑这是部署上的问题。
如果您无法控制它,您可以手动下载JAR并将其安装到本地的m2回购中并以这种方式构建吗?这应该能让你度过难关直到修好为止。
发布于 2014-11-07 18:45:07
如果需要使用依赖关系创建jar,则可以使用maven-程序集-插件的单个目标。
...
<build>
...
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>MAIN_CLASS</mainClass>
</manifest>
</archive>
<!-- <finalName>JAR_NAME/finalName> -->
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
...
</build>
...这个插件被添加到maven生命周期(<phase>package</phase>)的打包阶段。jar与依赖关系生成一个只包含所有依赖项的jar。
https://stackoverflow.com/questions/26807683
复制相似问题