eclipse Maven 错误:'dependencies.dependency.version' for ... 必须是一个有效版本,但是是

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15614707/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 20:15:18  来源:igfitidea点击:

Maven error: 'dependencies.dependency.version' for ... must be a valid version but is

eclipseexceptionmavenpom.xml

提问by lakshman

I created a maven project using eclipse juno and edited the pom file. when I ran the pom file using command prompt by "mvn clean install", I got this error.

我使用 eclipse juno 创建了一个 maven 项目并编辑了 pom 文件。当我通过“mvn clean install”使用命令提示符运行 pom 文件时,出现此错误。

[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR]   The project se.cambio.platform.sdk:sdk-documentation-samples-laki:1      (F:\newWorkspace\sdk-documentation-samples-laki\pom.xml) has 2 errors
[ERROR]     'dependencies.dependency.version' for se.cambio.platform.sdk:sdk-client:jar    must be a valid version but is '${version.sdk.client}'. @ line 38, column 16
[ERROR]     'dependencies.dependency.version' for se.cambio.platform.sdk:sdk-common:jar   must be a valid version but is '${version.sdk.common}'. @ line 44, column 16
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException

my pom file is,

我的 pom 文件是,

<?xml version="1.0" encoding="UTF-8"?>
<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>se.cambio.platform.sdk</groupId>
<artifactId>sdk-documentation-samples</artifactId>
<version>0.8.2</version>
</parent>
<artifactId>sdk-documentation-samples-laki</artifactId>
<version>1</version>
<description>this is a sample project</description>
<build>
<plugins>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <configuration>
      <archive>
        <manifestEntries>
          <ModuleClass>se.cambio.laki.client.Module</ModuleClass>
          <BuildVersion>${pom.version}</BuildVersion>
        </manifestEntries>
      </archive>
    </configuration>
  </plugin>
 </plugins>
</build>
<dependencies>
<dependency>
  <groupId>${project.groupId}</groupId>
  <artifactId>sdk-client</artifactId>
  <version>${version.sdk.client}</version>
  <scope>compile</scope>
</dependency>
<dependency>
  <groupId>${project.groupId}</groupId>
  <artifactId>sdk-common</artifactId>
  <version>${version.sdk.common}</version>
  <scope>compile</scope>
</dependency>
<dependency>
  <groupId>se.cambio.legacy</groupId>
  <artifactId>CDK</artifactId>
  <version>${version.cde}</version>
  <classifier>cdk-internal</classifier>
  <scope>runtime</scope>
</dependency>
<dependency>
  <groupId>commons-dbcp</groupId>
  <artifactId>commons-dbcp</artifactId>
  <version>1.4</version>
  <scope>runtime</scope>
</dependency>
        <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>${version.testng}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.mockito</groupId>
        <artifactId>mockito-all</artifactId>
        <version>1.8.5</version>
        <scope>test</scope>
    </dependency>
<dependency>
  <groupId>net.sourceforge.jtds</groupId>
  <artifactId>jtds</artifactId>
  <version>1.2.5</version>
  <scope>runtime</scope>
  </dependency>
<dependency>
        <groupId>cglib</groupId>
        <artifactId>cglib</artifactId>
        <version>2.2</version>
        <scope>test</scope>
    </dependency>
 </dependencies>
  </project>

how I can resolve this error?

我该如何解决这个错误?

回答by ben75

The properties ${version.sdk.client}and ${version.sdk.common}aren't defined in your project.

属性${version.sdk.client}${version.sdk.common}未在您的项目中定义。

Adding something like this will solve the problem. (be sure to adapt the version of course; 1.0.0.RELEASE is probably not what you need.)

添加这样的东西将解决问题。(当然一定要适应版本;1.0.0.RELEASE 可能不是你需要的。)

<properties>
    <version.sdk.client>1.0.0.RELEASE</version.sdk.client>
    <version.sdk.common>1.0.0.RELEASE</version.sdk.common>
</properties>

回答by Stijn Haus

Add the correct properties:

添加正确的属性:

<properties>
    <version.sdk.client>1.0</version.sdk.client>
    <version.sdk.common>1.0</version.sdk.common>
</properties>

Make sure you enter the correct version, though.

不过,请确保输入正确的版本。